← Years 5–6 Creating Digital Solutions

The if-else block

A block that runs the blocks in the first part if the condition is true, and the blocks in the else part if it is false. Two paths, but only one runs.

Understanding The if-else block in Years 5–6 Creating Digital Solutions

What it does: If the answer is not yes, the condition is false, so the sprite says Maybe next time instead of Great!. The sprite either moves or turns, never both, because the condition picks just one path. When the condition is true, only the first part runs. The else part is skipped. If-else gives two choices. Repeating is done with loops such as forever or repeat. The if-else block always checks one condition and then picks one of its two paths.

Common mistakes: The if-else block needs the word then after the condition. Line 2 should be: if <answer = yes> then. The second path of the block is called 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 51–60) and word search (Modules 41–74).

Take this worksheet further — free with Cloodit

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

Learning
Duo
What does an if-else block do when its condition is true?
It runs the blocks in the first part (the 'if' part) and skips the else partIt runs both the if part and the else part
Matches
if <(lives) = 0> then say [Game over] and say [Keep playing]
↓
There is no else part. A message for the false case should be in the else part, not joined on with 'and', or both messages would be said.
Applying
Meanings
Term
if <> then ... else ...
Meaning
A block that runs the blocks in the first part if the condition is true, and the blocks in the else part if it is false. Two paths, but only one runs.
Practice
if <(score) > 10> then
Testing
Gaps
<score > 10> then say [You win!]
Check Answer
Spots
1ask [Is it raining?] and wait
2if <answer = yes>

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

The 'Stag' badge — Forest 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. What does an if-else block do when its condition is true?
A. It runs the blocks in the first part (the 'if' part) and skips the else part ✓
B. It runs both the if part and the else part
When the condition is true, only the first part runs. The else part is skipped.
2. What does an if-else block do when its condition is false?
A. It does nothing at all
B. It runs the blocks in the else part ✓
An if-else block always has a second path. When the condition is false, the else part runs. A plain if block is the one that does nothing when false.
3. Which sentence describes an if-else block best?
A. Two paths, but only one runs ✓
B. Two paths, and both always run
The computer checks the condition and picks just one path each time.
4. A sprite checks: if <score > 10> then say 'You win!' else say 'Keep trying!'. The score is 4. What does the sprite say?
A. Keep trying! ✓
B. You win!
4 is not greater than 10, so the condition is false and the else path runs.
5. A sprite checks: if <answer = 7> then say 'Correct!' else say 'Try again'. The answer is 7. What happens?
A. The sprite says 'Correct!' and then 'Try again'
B. The sprite says 'Correct!' only ✓
The condition is true, so the if part runs and the else part is skipped. Only one path runs.

Match the Pairs

if <touching color [red]?> then ... else ... → Checks the condition. If it is true, the first set of blocks runs. If it is false, the else set of blocks runs.
if <(score) > 9> then say [You win!] else say [Keep going!] → If the score is more than 9, the sprite says You win!. If not, the sprite says Keep going! Only one message appears.
The blocks in the else part run only when the condition is false. → if <(answer) = [yes]> then say [Great!] else say [Maybe next time]
An if-else block gives two paths, but only one of them runs each time. → if <key [space] pressed?> then move (10) steps else turn (15) degrees
if <(lives) = 0> then say [Game over] and say [Keep playing] → There is no else part. A message for the false case should be in the else part, not joined on with 'and', or both messages would be said.
if <(score) > 5> then say [Well done!] else say [Well done!] → Both paths do the same thing, so the condition makes no difference. The else part should have different blocks, such as say Try again!.

Key Term

if <> then ... else ...
A block that runs the blocks in the first part if the condition is true, and the blocks in the else part if it is false. Two paths, but only one runs.

Fill in the Blanks

1. if <score > 10> then say [You win!] else say [Try again]
Hint: Type the keyword that starts the block and begins the condition check.
2. if <score > 10> then say [You win!] else say [Try again]
Hint: Type the keyword that starts the second path, which runs only when the condition is false.
3. if <score > 10> then say [You win!] else say [Try again]
Hint: Type the comparison operator that checks if the score is bigger than 10.
4. if <age < 8> then say [Hello, little one!] else say [Hello, big kid!]
Hint: Type the Looks block name that makes the sprite show a speech bubble.
5. if <score > 10> then say [You win!] else say [Try again]
Hint: Type the keyword that comes after the condition and leads into the first path.

Spot the Error

Question 1
A ask [Is it raining?] and wait
B if <answer = yes>
C say [Take an umbrella]
D else
E say [Wear a cap]
F end
Line B — The if-else block needs the word then after the condition. Line 2 should be: if <answer = yes> then.
Question 2
A if <touching edge?> then
B turn 15 degrees
C otherwise
D move 10 steps
E end
Line C — The second path of the block is called else, not otherwise. Line 3 should be: else.
Question 3
A if <score > 10> then
B say [You win!]
C else <score < 10>
D say [Try again]
E end
Line C — The else part has no condition of its own. It runs whenever the if condition is false. Line 3 should just be: else.
Question 4
A when green flag clicked
B if <lives = 0> then
C say [Keep going]
D else
E say [Keep going]
F end
Line C — The first path runs when lives = 0, so it should say Game over. Keep going belongs in the else part, so line 3 should be: say [Game over].
Question 5
A if <coins + 10> then
B say [You are rich!]
C else
D say [Keep saving]
E end
Line A — The if block needs a true or false condition. coins + 10 is a number, not a comparison. Line 1 should be: if <coins = 10> then.

Student with a class code? Join your class →