-
Notifications
You must be signed in to change notification settings - Fork 1
/
10.1_condtion.py
105 lines (84 loc) · 2.95 KB
/
10.1_condtion.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# use double condiiton:
name = 'Daksh'
name2 = 'Ram'
name3 = 'Shyam'
if name == 'Daksh':
print('\nHi', name , '\n')
# else name2 == 'Ram' and name3 == 'Shyam':
else:
print('\nHello ' + name2 + ' and ' + name3 + '\n')
# and = and me sabhi condtion ture hogi tabhi hum condtionn me enter karenge
# or = koi bhi ek cond. sahi hue hum condtion me enter kar lenge
# not = ye condtion ko accetp nai karenge iske alawa koi bhi conditon ho to enter karn lenge
if name != 'Daksh':
print('\nHi', name , '\n')
# else name2 == 'Ram' and name3 == 'Shyam':
else:
print('\nHello ' + name2 + ' and ' + name3 + '\n')
if name == 'Daksh' or name == 'Ram' or name == 'Shyam':
print('\nHi', name , '\n')
# else name2 == 'Ram' and name3 == 'Shyam':
else:
print('\nHello ' + name2 + ' and ' + name3 + '\n')
if name == 'Daksh' and name2 == 'Ram' and name3 == 'Shyam':
print('\nHi', name , ' all condtion are true.\n')
# else name2 == 'Ram' and name3 == 'Shyam':
else:
print('\nHello ' + name2 + ' and ' + name3 + '\n')
if not(name == 'Daksh1'):
print('\nHi', name , '\n')
# else name2 == 'Ram' and name3 == 'Shyam':
else:
print('\nHello not elese part \n')
# identity opr: is / is not
print('\ncheck name is Daksh or not: ', name is 'Daksh', '\n')
print('\ncheck name is Daksh or not: ', name is not 'Daksh', '\n')
# memebershitp orp: in / not in
name = ['daksh','ram','shyam','radha']
print('\nIs Daksh in name: ', 'daksh' in name)
# Multi condtions
# store dict value using input
bio_data = {
'name': input('\nEnter your name: '),
'mobile': int(input('\nEnter your mobile: ')),
'email': input('\nEnter your emial id: '),
}
my_data = '''\n
Hi my name is {} and my other details are as followes,
Mobile: {}
Email ID: {} \n
'''.format(bio_data['name'], bio_data['mobile'], bio_data['email'])
greeting = '''\n
----------------------------
Hi, {}
----------------------------
'''.format(bio_data['name'])
if bio_data['name'] == 'Daksh':
# my_data = '''\n
# Hi my name is {} and my other details are as followes,
# Mobile: {}
# Email ID: {} \n
# '''.format(bio_data['name'], bio_data['mobile'], bio_data['email'])
print(greeting)
print(my_data)
elif bio_data['name'] == 'Ram':
print(greeting)
print(my_data)
elif bio_data['name'] == 'Shyam':
print(greeting)
print(my_data)
else:
print(my_data)
if name == 'Ram':
pass
name = 'Ram'
# Home work
# Program:
# 1. user se input le kar chek karna hai ki wo jo value print kiya hai uska type kya hai wo kitne length ka hai.
# Is ko multiline string me kuch ayse show karna hai
# Your input is:
# Value name:
# value type:
# value length:
# 2. use ka bio data dictonary me store kara kar usko check karna hai user ka input null to nahi hai then multiline string ka use kar kar output show karwana hai.
# input galat hai to else me message show karna hai agian input ke liye.