1. Concept library
  2. Python Foundations
  3. Module 2: Control flow

Concept

Conditionals

if, elif and else choose which block runs from a condition that evaluates to true or false. Comparison and boolean operators build the condition.

What a session covers

The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.

  1. Explain how if, elif and else choose a branch from a condition
  2. Write a condition that combines comparisons with and, or and not
  3. Spot why "if x == 1 or 2" runs for every x and fix it

In practice

A few lines that show Conditionals doing its job.

Python
temperature = 31

if temperature >= 30:
    advice = "stay in the shade"
elif temperature >= 20:
    advice = "a good day for a walk"
else:
    advice = "bring a jacket"

print(advice)

The common mistake

Watch for

Writing if x == 1 or 2. The second operand is just the number 2, which is always truthy, so the branch runs for every x. Write x == 1 or x == 2, or x in (1, 2).

What to know first

Your roadmap puts these before Conditionals, unless you already know them.

How it stays learned

Once a session shows you understand Conditionals, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.

  1. Day 3First recall, while it is fresh
  2. Day 7Second, a week on
  3. Day 18Last, when it has settled

Where it leads

Topics that build on Conditionals.

Next in the modulewhile loops →