← Python

If Statements

An if statement runs a block of code only when its condition is True

What it does: An if statement runs a block of code only when its condition evaluates to True. The condition is any expression that resolves to True or False (like 5 > 3), the line must end with a colon, and the code that should run sits on the next line, indented underneath — usually by 4 spaces. That indentation isn't a style choice: it's how Python knows which lines belong inside the if block.

Common mistakes: Forgetting the trailing colon (if 5 > 3 instead of if 5 > 3:) is the single most common error. Inconsistent indentation is the other — mixing tabs and spaces, or indenting by a different amount than the rest of the block, raises an IndentationError.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a journey and assign it to your class.

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
What does the if statement check?
Whether a condition is TrueHow many times to loop
Matches
❌ if x > 5 print('big')
Error: Missing colon after if
Applying
Meanings
Term
if
Meaning
Runs the indented code only when the condition is True.
Practice
age = 15
Testing
Gaps
5 > 3:
Check Answer
Spots
1if 5 > 3: print('Yes')
2if 5 > 3 print('Yes')

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Hippopotamus' badge — Savannah Titan, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. What does the if statement check?
A. Whether a condition is True ✓
B. How many times to loop
if runs a block of code only when its condition is True
2. What goes at the end of an if line?
A. A semicolon ;
B. A colon : ✓
Python uses a colon : to start a block — if, elif, else, for, while, def all need it
3. How does Python know what's inside an if block?
A. Indentation (spaces) ✓
B. Curly braces {}
Python uses indentation (4 spaces) to define blocks — not curly braces like other languages
4. if 10 > 5:\n print('Yes')\nWhat prints?
A. Nothing
B. Yes ✓
10 > 5 is True, so the indented code runs
5. if 3 > 7:\n print('Yes')\nWhat prints?
A. Nothing ✓
B. Yes
3 > 7 is False, so the code inside is skipped

Match the Pairs

if x > 5 print('big') Error: Missing colon after if
if x > 5: print('big') Error: Body must be indented
if age >= 18: print('Adult') Valid: if with colon + indent
if True: print('yes') Ok: Always runs
x = 10 if x > 5: print('big') Output: big
x = 3 if x > 5: print('big') Output: (nothing)

Key Term

if
Runs the indented code only when the condition is True.~~Condition

Fill in the Blanks

1. if 5 > 3: print('Yes')
2. if age >= 13: print('Teen')
3. if x == 10: print('Match')
4. if score >= 50: print('Pass')
5. if name == 'Alice': print('Hi')

Spot the Error

Question 1
A if 5 > 3: print('Yes')
B if 5 > 3 print('Yes')
C if 10 > 8: print('Big')
D if x > 0: print('Positive')
Line B — Missing colon at the end of the if line
Question 2
A if 5 > 3: print('Yes')
B if x > 0: print('Positive')
C if done: print('Done')
D if ok: print('OK')
Line A — The print line must be indented (4 spaces) inside the if block
Question 3
A if 5 > 3: print('Yes')
B if ready: print('Go')
C If 10 > 5: print('Big')
D if name: print('Hi')
Line C — if must be lowercase — If is not valid Python
Question 4
A if done: print('Done') print('OK')
B if ok: print('A') print('B')
C if ready: print('Go') print('Start')
D if 5 > 3: print('Yes') print('Done')
Line D — Inconsistent indentation — both lines must use the same number of spaces
Question 5
A if score == 10: print('Match')
B if x = 5: print('Five')
C if age == 18: print('Adult')
D if n == 0: print('Zero')
Line B — Use == to compare, not = (which assigns a value)
For Teachers

Create a free class, add this module to a journey, and track who's stuck.

Create a free teacher account →

No credit card. No setup fee. Make a class and invite students in under three minutes.

For Students

Practice this topic interactively, track progress, and unlock badges.

Start Learning Free →

Have a class code?