Else-Statement-in-Python
Else-Statement-in-Python
STATEMENT
IN PYTHON
CONDITIONAL STATEMENTS
A Statement that makes the program smarter, it makes the
program decides on what to do in certain CONDITIONS.
CONDITIONAL STATEMENTS
A Statement that makes the program smarter, it makes the
program decides on what to do in certain CONDITIONS.
CONDITIONAL OPERATORS
• == - EQUAL
• != - NOT EQUAL
• > - GREATER THAN
• < - LESS THAN
• >= - GREATER THAN or EQUAL
• <= - LESS THAN or EQUAL
IF-ELSE STATEMENT
Used when dealing with TWO CONDITIONS.
SYNTAX EXAMPLE
if valueOne == valueTwo: if age >= 18:
#Do Something print("Legal Age")
else: else:
#Do Something print("Too Young")
IF-ELIF-ELSE STATEMENT
Used when dealing with THREE OR MORE CONDITIONS.
SYNTAX EXAMPLE
if valueOne == valueTwo: if age >= 18:
#Do Something print("Legal Age")
elif valueOne >= valueTwo: elif age >= 13:
#Do Something print("Teenager")
else: else:
#Do Something print("Too Young")
NESTED CONDITIONAL STATEMENT
Used when dealing with CONDITIONS INSIDE A CONDITION.
SYNTAX EXAMPLE
if valueOne == valueTwo: if age >= 18:
if valueThree == valueFour: if height >= 170:
#Do Something print(“Legal Age and Tall”)
elif valueThree == valueFive: elif height >= 156:
#Do Something print(“Legal Age and
else: Average)
#Do Something else:
print(“Legal Age and Short”)