Skip to content

Python Conditional Statements

Use if else and elif to make decisions. The statements end with a colon and indentation of sub blocks is required.

num = 10

if (num > 10):
    print("The number is greater than 10")
elif (num == 10):
    print("The number is equal to 10")
else:
    print("The number is less than 10")

Can also put multiple condition in an if statement:

if (num > 10) and (num < 50):
    print("Number greater than 10 and less than 50")

tagcheck

tagcheck