Decision making if elif else
This commit is contained in:
65
src/basic/if_else.py
Normal file
65
src/basic/if_else.py
Normal file
@@ -0,0 +1,65 @@
|
||||
# Python If ... Else
|
||||
a = 33
|
||||
b = 200
|
||||
if b > a:
|
||||
print("b is greater than a")
|
||||
|
||||
# Elif
|
||||
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")
|
||||
|
||||
if a > b:
|
||||
print("a is greater than b")
|
||||
|
||||
a = 100
|
||||
b = 900
|
||||
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")
|
||||
|
||||
a = 33
|
||||
b = 200
|
||||
if not a > b:
|
||||
print("a is NOT greater than b")
|
||||
|
||||
x = 41
|
||||
|
||||
if x > 10:
|
||||
print("Above ten,")
|
||||
if x > 20:
|
||||
print("and also above 20!")
|
||||
else:
|
||||
print("but not above 20.")
|
||||
|
||||
|
||||
a = 33
|
||||
b = 200
|
||||
|
||||
if b > a:
|
||||
pass
|
||||
Reference in New Issue
Block a user