← Years 5–6 Creating Digital Solutions

Branching with IF ... THEN

Runs the indented action only when the condition is true. If the condition is false, the action is skipped. Write IF and THEN in capitals, indent the action, and finish with END IF.

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

What it does: The indented line show "Well done!" sits inside the IF block, so it runs only when score > 10 is true. If the door is not open, 'walk through' is skipped. 'say hello' is outside the block, so it still runs. In our pseudocode, IF and THEN are written in capital letters so they stand out from the rest of the line. The action sits inside the branch, so we indent it. The indent shows which step belongs to the IF. END IF shows where the branch finishes. Steps after it happen no matter what the condition was. The condition sits between IF and THEN. It is the question that is either true or false. 'walk through' is the action.

Common mistakes: The IF line is missing THEN. It should be 'IF score > 10 THEN' so the computer knows the action comes next. An IF block must finish with END IF, not just END. The last line should be 'END IF'.

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
Which line correctly starts a branch in pseudocode?
if it is raining thenIF it is raining THEN
Matches
if battery is low then plug in charger end if
↓
IF, THEN and END IF must be written in capital letters so they stand out from the rest of the steps.
Applying
Meanings
Term
IF condition THEN action END IF
Meaning
Runs the indented action only when the condition is true. If the condition is false, the action is skipped. Write IF and THEN in capitals, indent the action, and finish with END IF.
Practice
IF it is raining THEN
Testing
Gaps
it is raining THEN
Check Answer
Spots
1SET score TO 12
2IF score > 10

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

The 'Golden Phoenix' badge — Savannah Legend, 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. Which line correctly starts a branch in pseudocode?
A. IF it is raining THEN ✓
B. if it is raining then
In our pseudocode, IF and THEN are written in capital letters so they stand out from the rest of the line.
2. The condition is false. What happens to the action inside IF ... THEN?
A. The action is skipped ✓
B. The action still runs
The action only runs when the condition is true. If it is false, the computer skips it and moves on.
3. Which one is set out correctly?
A. IF score = 10 THEN play a sound END IF ✓
B. IF score = 10 THEN play a sound END IF
The action sits inside the branch, so we indent it. The indent shows which step belongs to the IF.
4. How do you finish an IF ... THEN branch?
A. STOP
B. END IF ✓
END IF shows where the branch finishes. Steps after it happen no matter what the condition was.
5. Which part is the condition in this branch? IF door is open THEN walk through END IF
A. walk through
B. door is open ✓
The condition sits between IF and THEN. It is the question that is either true or false. 'walk through' is the action.

Match the Pairs

IF it is raining THEN → Checks the condition 'it is raining'. The indented action below runs only if it is true.
END IF → Marks the end of the IF block so the computer knows where the branching stops.
The action is indented so it is clearly part of the IF block and runs only when the condition is true. → IF score > 10 THEN show "Well done!" END IF
If the condition is false, the action is skipped and the program carries on after END IF. → IF door is open THEN walk through END IF say hello
if battery is low then plug in charger end if → IF, THEN and END IF must be written in capital letters so they stand out from the rest of the steps.
IF lights are off THEN turn on the lights → The action is not indented and there is no END IF to close the block.

Key Term

IF condition THEN action END IF
Runs the indented action only when the condition is true. If the condition is false, the action is skipped. Write IF and THEN in capitals, indent the action, and finish with END IF.

Fill in the Blanks

1. IF it is raining THEN take an umbrella END IF
Hint: Type the capital-letter keyword that starts a decision.
2. IF it is raining THEN take an umbrella END IF
Hint: Type the capital-letter keyword that comes after the condition and before the action.
3. IF it is dark THEN turn on the lamp END IF
Hint: Type the two capital-letter words that finish the decision block.
4. IF score > 10 THEN SHOW "You win" END IF
Hint: Type the symbol that checks if the score is greater than 10.
5. IF door = locked THEN use the key END IF
Hint: Type the symbol that checks if two things are equal.

Spot the Error

Question 1
A SET score TO 12
B IF score > 10
C SAY "Well done!"
D END IF
Line B — The IF line is missing THEN. It should be 'IF score > 10 THEN' so the computer knows the action comes next.
Question 2
A IF temp < 15 THEN
B SAY "Wear a jacket"
C END
Line C — An IF block must finish with END IF, not just END. The last line should be 'END IF'.
Question 3
A SET bell TO "rang"
B if bell = "rang" then
C SAY "Time for recess"
D END IF
Line B — IF and THEN must be written in capitals. The line should be 'IF bell = "rang" THEN'.
Question 4
A SET weather TO "hot"
B IF weather = "hot" THEN
C SAY "Wear a hat"
D END THEN
Line D — The block must finish with END IF. THEN belongs at the end of the IF line, so line 4 should be 'END IF'.
Question 5
A IF door is open
B walk through
C END IF
Line A — The IF line is missing THEN. It should be 'IF door is open THEN' so the computer knows the action comes next.

Student with a class code? Join your class →