← Years 5–6 Creating Digital Solutions

Branching with IF ... THEN ... ELSE

Chooses between two paths. If the condition is true, action1 runs. If it is false, the ELSE path runs action2 instead. Exactly one of the two paths runs.

Understanding Branching with IF ... THEN ... ELSE in Years 5–6 Creating Digital Solutions

What it does: The condition score >= 10 is true or false. True gives the prize path and false gives the try again path, so there are two outcomes. When the light is green, the THEN path runs and you go. When it is any other colour, the ELSE path runs and you stop. Never both. An IF ... ELSE is meant to choose between two different paths. If both do the same thing, the condition makes no difference.

Common mistakes: ELSE never has its own condition. It just means 'otherwise'. Line 4 should be just ELSE. The keyword for the second path is ELSE, not OTHERWISE. Line 3 should be ELSE.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 11–20) and word search (Modules 1–20).

Take this worksheet further — free with Cloodit

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

Learning
Duo
IF it is raining THEN take an umbrella ELSE wear a hat. It is raining. What happens?
Take an umbrellaWear a hat
Matches
IF it is cold THEN wear a jumper ELSE wear a jumper
↓
Both paths do the same action, so the ELSE path does not give a different outcome. The ELSE action should be something else, like wear a t-shirt.
Applying
Meanings
Term
IF condition THEN action1 ELSE action2
Meaning
Chooses between two paths. If the condition is true, action1 runs. If it is false, the ELSE path runs action2 instead. Exactly one of the two paths runs.
Practice
IF it is raining THEN
Testing
Gaps
door is open THEN close it ELSE open it
Check Answer
Spots
3 SAY wear a jumper
4ELSE temperature >= 15

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

The 'Woolly Mammoth' badge — Tundra Master, 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. IF it is raining THEN take an umbrella ELSE wear a hat. It is raining. What happens?
A. Take an umbrella ✓
B. Wear a hat
The condition 'it is raining' is true, so the THEN path runs. The ELSE path is skipped.
2. IF the light is green THEN go ELSE stop. The light is red. What happens?
A. Go
B. Stop ✓
The condition 'the light is green' is false, so the ELSE path runs and the THEN path is skipped.
3. In IF ... THEN ... ELSE, how many of the two paths run each time?
A. Both paths
B. Exactly one path ✓
The algorithm chooses between two paths. Only one runs, never both.
4. When does the ELSE path run?
A. When the condition is false ✓
B. When the condition is true
ELSE means 'otherwise'. It runs only when the IF condition is false.
5. Which algorithm gives a choice between two outcomes?
A. IF score > 10 THEN say 'Win' ELSE say 'Try again' ✓
B. IF score > 10 THEN say 'Win'
Only the version with ELSE gives a second path. Without ELSE, nothing happens when the condition is false.

Match the Pairs

IF raining THEN take umbrella ELSE wear sunhat → Chooses between two paths: take the umbrella if it is raining, otherwise wear the sunhat. Only one happens.
ELSE wear sunhat → The path that runs when the condition is false
Two outcomes: if the score is 10 or more you get a prize, otherwise you try again → IF score >= 10 THEN give prize ELSE try again
Following each path: if the light is green you go, but if it is not green you stop → IF light is green THEN go ELSE stop
IF it is cold THEN wear a jumper ELSE wear a jumper → Both paths do the same action, so the ELSE path does not give a different outcome. The ELSE action should be something else, like wear a t-shirt.
IF door is locked THEN use key ELSE → The ELSE has no action after it. It needs a second action, like push the door open.

Key Term

IF condition THEN action1 ELSE action2
Chooses between two paths. If the condition is true, action1 runs. If it is false, the ELSE path runs action2 instead. Exactly one of the two paths runs.

Fill in the Blanks

1. IF door is open THEN close it ELSE open it
Hint: Type the keyword that starts a decision and introduces the condition.
2. IF it is raining THEN take an umbrella ELSE wear a cap
Hint: Type the keyword that begins the second path, which runs when the condition is false.
3. IF score > 10 THEN show "You win!" ELSE show "Try again"
Hint: Type the keyword that comes after the condition and leads to the first path.
4. IF temperature > 25 THEN wear shorts ELSE wear jeans
Hint: Type the comparison operator that checks if the temperature is more than 25.
5. IF the light is green THEN go ELSE stop
Hint: Type the action for the other path, when the light is not green.

Spot the Error

Question 1
A ASK for the temperature
B IF temperature < 15 THEN
C SAY wear a jumper
D ELSE temperature >= 15
E SAY wear a t-shirt
F END IF
Line D — ELSE never has its own condition. It just means 'otherwise'. Line 4 should be just ELSE.
Question 2
A IF score > 10 THEN
B SAY You win
C OTHERWISE
D SAY Try again
E END IF
Line C — The keyword for the second path is ELSE, not OTHERWISE. Line 3 should be ELSE.
Question 3
A SET age TO 9
B IF age >= 12
C SAY Teen ticket
D ELSE
E SAY Child ticket
F END IF
Line B — The IF line is missing THEN after the condition. It should be IF age >= 12 THEN.
Question 4
A IF the door is open THEN
B walk inside
C ELSE
D walk inside
E END IF
Line D — Both paths now do the same thing, so there is no real choice. The ELSE path should do something different, like knock on the door.
Question 5
A SET coins TO 3
B IF coins < 5 THEN
C buy the game
D ELSE
E keep saving
F END IF
Line B — The condition is the wrong way around. With 3 coins the program would buy the game. It should be IF coins >= 5 THEN.

Student with a class code? Join your class →