14. If Statements - tomaslt99/Python-language-tutorials GitHub Wiki
If Statements
Code:
is_male = False
if is_male:
print("You are a male.")
else:
print("You are not a male.")
Code:
is_male = True
is_tall = True
if is_male or is_tall: # give 2 condition one of them has to be correct.
print("You are a male or tall or both.")
else:
print("You neither male nor tall.")
Output:
You are a male or tall or both.
Code:
is_male = True
is_tall = True
if is_male and is_tall: # give 2 condition one of them has to be correct.
print("You are a male or tall or both.")
else:
print("You neither male nor tall.")
Output:
You are a male or tall or both.
Code:
is_male = False
is_tall = True
if is_male and is_tall: # give 2 condition one of them has to be correct.
print("You are a male or tall or both.")
elif is_male and not (is_tall):
print("You are a short male.")
elif not is_male and is_tall:
print("You are a short male.")
else:
print("You neither male nor tall.")
Output:
You are a short male.