← Years 5–6 Creating Digital Solutions

The if block

A block that runs the blocks inside it only when its condition is true. If the condition is false, it skips them. The condition goes in the hexagon slot.

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

What it does: The condition 'key space pressed?' is placed in the hexagon slot next to the word if. The say block is inside the if block, so the sprite only says Great! when the answer is yes. 3 is not greater than 5, so the condition is false and the say block inside is skipped.

Common mistakes: The slot needs a true or false condition. Score + 10 makes a number, not true or false. It should be if <score > 10> then. The condition goes in the hexagon slot straight after if, and then comes after it. It should be if <touching [Ball]?> then.

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 the if block do?
It runs the blocks inside it only when its condition is trueIt runs the blocks inside it every time, no matter what
Matches
if <say Hello> then
↓
A say block was put in the condition slot. The slot needs a true or false question, like <answer = yes>. The say block should go inside the if block.
Applying
Meanings
Term
if <condition> then
Meaning
A block that runs the blocks inside it only when its condition is true. If the condition is false, it skips them. The condition goes in the hexagon slot.
Practice
when green flag clicked
Testing
Gaps
<score > 10> then
Check Answer
Spots
1if <score + 10> then
2 say [You win!]

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

The 'Mantis Shrimp' badge — Speed Striker, 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 block do?
A. It runs the blocks inside it only when its condition is true ✓
B. It runs the blocks inside it every time, no matter what
The if block checks its condition first. The blocks inside only run when the condition is true.
2. Where does the condition go in an if block?
A. In the hexagon slot next to the word if ✓
B. Inside the blocks in the middle of the C shape
The condition fits into the hexagon-shaped slot at the top of the if block. The blocks that run go inside the C shape.
3. Which blocks run if the condition is false?
A. None of the blocks inside the if block ✓
B. All of the blocks inside the if block
When the condition is false, the if block skips the blocks inside it and the script moves on.
4. Which block belongs inside an if block so the sprite says 'Ouch!' only when it touches the edge?
A. say Ouch! (placed above the if block)
B. say Ouch! (inside the if touching edge? block) ✓
A block only depends on the condition when it is placed inside the if block. A block above it runs every time.
5. Which one fits in the condition slot of an if block?
A. move 10 steps
B. score > 10 ✓
The condition slot needs a hexagon block that is true or false, like score > 10. Move is a stack block, so it goes inside the if block.

Match the Pairs

if <score > 10> then → The blocks inside this if block run only when the score is greater than 10.
if <touching edge?> then turn 15 degrees → The sprite turns only when it is touching the edge. Otherwise the turn block is skipped.
The condition goes in the hexagon slot of the if block → if <key space pressed?> then
Blocks that should only run sometimes go inside the if block → if <answer = yes> then say Great!
if <say Hello> then → A say block was put in the condition slot. The slot needs a true or false question, like <answer = yes>. The say block should go inside the if block.
if <score > 10> then say You win! (say is outside the if) → The say block is outside the if block, so it runs every time, even when the score is 10 or less. It should be placed inside the if block.

Key Term

if <condition> then
A block that runs the blocks inside it only when its condition is true. If the condition is false, it skips them. The condition goes in the hexagon slot.

Fill in the Blanks

1. if <score > 10> then say(You win!) end
Hint: Type the keyword that starts the block which runs code only when something is true.
2. if <lives = 0> then say(Game over) end
Hint: Type the word that comes after the condition and leads into the blocks inside.
3. if <score > 10> then say(Well done!) end
Hint: Type the comparison symbol that checks if the score is bigger than 10.
4. if <score > 10> then say(You win!) end
Hint: Type the Looks block name that goes inside the if block and makes the sprite speak.
5. if <touching edge?> then turn 15 degrees end
Hint: Type the word that closes the if block after the blocks inside.

Spot the Error

Question 1
A if <score + 10> then
B say [You win!]
C end
Line A — The slot needs a true or false condition. Score + 10 makes a number, not true or false. It should be if <score > 10> then.
Question 2
A when green flag clicked
B if then <touching [Ball]?>
C say [Got it!] for 2 seconds
D end
Line B — The condition goes in the hexagon slot straight after if, and then comes after it. It should be if <touching [Ball]?> then.
Question 3
A when green flag clicked
B set [score] to 12
C if <score > 10> then
D say <Well done!>
E end
Line D — The say block takes text in a rounded slot. The hexagon shape is only for conditions. It should be say [Well done!].
Question 4
A when green flag clicked
B if <score > 9> then
C say [High score!]
D then
Line D — An if block must be closed with end after the blocks inside it. The word then belongs on the first line. Line 4 should be end.
Question 5
A when green flag clicked
B ask [Ready?] and wait
C if <answer> then
D say [Let's go!]
E end
Line C — The answer on its own is text, not true or false. The condition must compare it, like <answer = [yes]>.

Student with a class code? Join your class →