← Years 5–6 Creating Digital Solutions

Multiple alternatives with nested if blocks

An if-else block placed inside the else part of another if-else block. The program checks one condition at a time, in order, so it can choose between three or more alternatives.

Understanding Multiple alternatives with nested if blocks in Years 5–6 Creating Digital Solutions

What it does: Checking score > 89 first means high scores stop at A. If score > 69 were first, a score of 95 would wrongly get a B. The nested if-else block in the else part is how a visual program builds the ELSE IF step from the written algorithm. A single if-else only has two paths. Putting a second if-else inside the else gives a third path. The program checks one condition at a time, in order. 85 is more than 49, so it stops at 'B' and never checks for 'A'. Three alternatives need two decisions. The first if-else picks A or not. The nested one picks B or C.

Common mistakes: The first check is for scores over 89, so this branch must say A, the top grade. It should be say A. The inner check uses < so it would say Warm for cold days. It should be temp > 19 to match the band between 20 and 29.

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
A program needs to choose between THREE different messages. Which setup works in a visual editor?
One if-else block with three conditions and no other blocksAn if-else block placed inside the else part of another if-else block
Matches
if score > 69 then say B else (if score > 89 then say A else say C)
↓
The checks are in the wrong order. A score of 95 is more than 69, so it says B and never reaches the check for A.
Applying
Meanings
Term
nested if-else
Meaning
An if-else block placed inside the else part of another if-else block. The program checks one condition at a time, in order, so it can choose between three or more alternatives.
Practice
if score > 79 then
Testing
Gaps
score > 49 then say("B") else
Check Answer
Spots
1if score > 89 then
2 say B

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. A program needs to choose between THREE different messages. Which setup works in a visual editor?
A. An if-else block placed inside the else part of another if-else block ✓
B. One if-else block with three conditions and no other blocks
A single if-else only has two paths. Putting a second if-else inside the else gives a third path.
2. How many alternatives can ONE if-else block with nothing inside it choose between?
A. Three
B. Two ✓
If-else gives one path when the condition is true and one path when it is false. For more paths, nest another if-else in the else.
3. Score bands: score > 79 says 'A', score > 49 says 'B', otherwise says 'C'. Which check should go in the OUTER if?
A. score > 79 ✓
B. score > 49
Check the highest band first. If the outer check was score > 49, a score of 90 would get 'B' and never reach 'A'.
4. A student's score is 85. The outer if checks score > 49 first and says 'B'. What goes wrong?
A. The program says 'B' when it should say 'A', because the order of checks is wrong ✓
B. The program says 'A' because it checks every block at once
The program checks one condition at a time, in order. 85 is more than 49, so it stops at 'B' and never checks for 'A'.
5. In the nested blocks, when does the INNER if-else run?
A. Every time, before the outer condition is checked
B. Only when the outer condition is false ✓
The inner block sits in the else part, so it only runs when the first condition is false.

Match the Pairs

if score > 89 then say A else (if score > 69 then say B else say C) → An if-else block sits inside the else part of another if-else block, so the program can choose between three results: A, B or C.
else (if score > 49 then say Pass else say Try again) → If the first check fails, the program moves on to this next check and picks one of two new answers.
The order of checks matters: check the highest score band first so a score of 95 gets an A and not a B. → if score > 89 then A else (if score > 69 then B else C)
A nested if-else is the same as the algorithm's ELSE IF: IF score > 89 THEN A, ELSE IF score > 69 THEN B, ELSE C. → if score > 89 then say A else (if score > 69 then say B else say C)
if score > 69 then say B else (if score > 89 then say A else say C) → The checks are in the wrong order. A score of 95 is more than 69, so it says B and never reaches the check for A.
if score > 89 then say A else say B (if score > 69 then say C) → The second if block is placed after the else block instead of inside the else part, so there is no real third choice and the program can't choose properly between three alternatives.

Key Term

nested if-else
An if-else block placed inside the else part of another if-else block. The program checks one condition at a time, in order, so it can choose between three or more alternatives.

Fill in the Blanks

1. if score > 79 then say("A") else if score > 49 then say("B") else say("C")
Hint: Type the keyword that starts the second check, placed inside the else part.
2. if score > 79 then say("A") else if score > 49 then say("B") else say("C")
Hint: Type the comparison operator that means 'greater than'.
3. if score > 79 then say("A") else if score > 49 then say("B") else say("C")
Hint: Type the name of the variable that holds the student's mark.
4. if score > 79 then say("A") else if score > 49 then say("B") else say("C")
Hint: Type the Looks block name that shows the grade in a speech bubble.
5. if score > 79 then say("A") else if score > 49 then say("B") else say("C")
Hint: Type the keyword that sends the program to the last choice when no check was true.

Spot the Error

Question 1
A if score > 89 then
B say B
C else
D if score > 79 then say B
E else say C
Line B — The first check is for scores over 89, so this branch must say A, the top grade. It should be say A.
Question 2
A if temp > 29 then
B say Hot
C else
D if temp < 19 then say Warm
E else say Cold
Line D — The inner check uses < so it would say Warm for cold days. It should be temp > 19 to match the band between 20 and 29.
Question 3
A if score > 59 then say A
B else
C if score > 79 then say B
D else say C
Line A — The first check must be the highest band. With > 59, scores like 70 would say A and the later checks would never run. It should be score > 89.
Question 4
A if age < 5 then say Free
B else
C if age < 13 say Child
D else say Adult
Line C — The word then is missing. Every if block needs a condition followed by then. It should be if age < 13 then say Child.
Question 5
A if stars = 3 then say Great
B else
C if stars = 3 then say Good
D else say Try again
Line C — The program already checked for 3 stars in the first if, so this check can never be true. It should check stars = 2.

Student with a class code? Join your class →