-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython if else statement.py
More file actions
80 lines (67 loc) · 1.26 KB
/
python if else statement.py
File metadata and controls
80 lines (67 loc) · 1.26 KB
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
a = 33
b = 200
if b > a:
print("b is greater than a")
a = 33
b = 200
if b > a:
print("b is greater than a") # you will get an error
a = 33
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
a = 200
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
else:
print("a is greater than b")
a = 200
b = 33
if b > a:
print("b is greater than a")
else:
print("a is greater than b")
if a > b: print("a is greater than b")
a = 2
b = 330
print("A") if a > b else print("B")
a = 200
b = 33
c = 500
if a > b and c > a:
print("Both conditions are True")
a = 200
b = 33
c = 500
if a > b or a > c:
print("At least one of the conditions is True")
x = 41
if x > 10:
print("Above ten,")
if x > 20:
print("and also above 20!")
else:
print("but not above 20.")
x=12
if x > 10:
print("Above ten,")
if x > 20:
print("and also above 20!")
else:
print("but not above 20.")
x = 1 #y did this code not run
if x > 10:
print("Above ten,")
if x > 20:
print("and also above 20!")
else:
print("but not above 20.")
a = 33 # having an empty if statement like this, would raise an error without the pass statement
b = 200
if b > a:
pass