Decisions inside loops in a visual program
An if block placed inside a loop is checked again on every repeat, so the program makes a new decision each time round, like in forever or repeat until.
Understanding Decisions inside loops in a visual program in Years 5–6 Creating Digital Solutions
What it does: The if is placed inside forever, so the sprite checks for red again and again. Each repeat tests the if block for the enemy, while the loop itself stops when lives = 0. Only blocks inside the loop are repeated. To keep watching the keyboard, the if must go inside the forever block. Checking the condition on every repeat lets the sprite react to things that change, like a key press or touching a colour.
Common mistakes: The if block must sit inside a forever loop so it is checked on every repeat. With repeat 1, the loop runs only once, so the sprite checks for the edge just one time. Line 1 should be forever. Each time the if block is true, the score should go up by 1. Setting it to 1 every time means the score never reaches 5, so the loop never ends. Line 4 should be change score by 1.
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 61–74) 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.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
if inside a loopFill in the Blanks
Spot the Error
Student with a class code? Join your class →