Lazo Lab Sign up

Read Python Like a Pro / Reading code

Lesson 3 of 10

Reading conditions

When you see an if, work out whether its condition is True or False with the current values. Only one branch of an if / elif / else ever runs.

Key points

  • Evaluate the condition with real values
  • Only the first True branch runs
  • else runs when nothing above matched
age = 13
if age >= 18:
    print("adult")
elif age >= 13:
    print("teen")
else:
    print("child")

Your turn

Change age to 18, then to 7. Predict the output each time before running.

Watch a video on thisOpens YouTube search results for “Reading conditions” in a new tab

Quiz · +10 XP

What does the code print?

Log in to save progress and earn XP.