if elif in text python code example
Example 1: if statement in python
#Conditionals statements in python
#'=' conditionals statements
a = 123
b = 123
if(a==b):
print('True')
#<, > conditionals statements
a = 2
b = 45
if(a<b):
print('A is smaller than B')
Example 2: python if statement
if (condition1):
print('condition1 is True')
elif (condition2):
print('condition2 is True')
else:
print('None of the conditions are True')
Example 3: python if elif
num = 20
if num > 30:
print("big")
elif num == 30:
print("same")
else:
print("small")
#output: small