Variables in an algorithm
A variable is a named place that stores a value. SET gives it a value, like 0, and later steps can change it, such as ADD 1 to score, so it works as a counter.
Understanding Variables in an algorithm in Years 5–6 Creating Digital Solutions
What it does: Setting lapCount to 0 gives the counter its starting value before any laps are counted. lives is first set to 3 and then changed by the next step, so it now holds 4. SET gives a variable a value. Here the variable score starts at 0. A variable is a named place that holds a value. 'lives' is a name we choose. TO is part of the SET instruction. ADD 1 to score changes the stored value so it is one bigger each time. SET replaces the old value. The variable now stores 5. That is why it is called a variable. Later steps can change what it stores.
Common mistakes: The variable was named score, but this line adds to points, which was never set. It should be ADD 1 TO score. There is no variable called scores. The variable is named score, so the line should be DISPLAY score.
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.
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
SET score TO 0Fill in the Blanks
Spot the Error
Student with a class code? Join your class →