how to make if statements in python code example
Example 1: how to use an if statement in python
x = True
#Only one of the branches will ever execute
if x == True:
print("x is true")
elif x == False:
print("x is false")
else:
print("x is neither true nor false")
Example 2: if statement python
#a statement that checks if a condition is correct
#example:
x=5
if x == 5:
print("x is 5")
else:
print("x is not 5")
Example 3: python if
if num<5:
print('Num less than 5')
elif 5<= num <=9:
print('Num between 5 and 9')
else:
print('Num more than 9')
Example 4: else if python
if (condion):
result
elif (condition):
results
else:
result
Example 5: if statements python
water = input('Does your creature live underwater?')
if water == 'yes':
print('Your creature lives underwater')
else:
print('Your creature does not live underwater')