-
Notifications
You must be signed in to change notification settings - Fork 0
/
ifelse1.py
70 lines (60 loc) · 1.01 KB
/
ifelse1.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
a = 22
b = 220
if a > b:
print("a is greater than b")
elif a == b:
print("a is equal to b")
else:
print("b is greater than a")
print()
#short hand if
a = 220
b = 39
if a > b: print("a is greater than b")
print()
#short hand if else
a = 220
b =39
print ("A") if b>a else print("B")
print()
#technique is called Ternary Operators, or Conditional Expression
#multiple conditions in one statement
a = 220
b = 220
print("A") if a > b else print("=") if a == b else print("B")
print()
#AND
a = 456
b = 234
c = 23
if a > b and b > c:
print("both conditions are true")
print()
#OR
a = 456
b = 234
c = 23
if a > b or c > a:
print("atleast one of the conditiona are true")
print()
#NOT
a = 456
b = 234
c = 23
if not b > a:
print("b is not greater than a")
print()
#NESTED IF
x = 2
if x > 10:
print("Above 10")
if x < 20:
print("also above 20")
else:
print("but not above 20")
print()
#PASS
a = 80
b = 40
if a < b:
pass