Starlit Daily

📚 › Python: the friendliest first language

7. Making decisions

An if statement runs its block only when the condition is True. elif checks another condition and else handles everything else. Indent the block with four spaces: Python uses indentation to know which lines belong together.

Use == for equal and != for not equal.

Show example

marks = 65
if marks >= 80:
    print("A")
elif marks >= 50:
    print("B")
else:
    print("C")

✍️ Your turn

Let temperature = 35. Print hot if it is above 30, otherwise mild.

← Back to course