← ACARA Digital Technologies Years 5–6

Working out the purpose of an algorithm

What the whole algorithm achieves. Follow the steps, check what it SHOWS and read the variable names for clues, then say it in one sentence.

Understanding Working out the purpose of an algorithm in ACARA Digital Technologies Years 5–6

What it does: The name lapsRun hints that the algorithm counts laps, and the loop stops at 10 laps. The messages shown are about voting, so the purpose is to check if someone is old enough to vote. The SHOW step displays total, and total is built by adding every price. So the algorithm adds up prices. Purpose is about the whole algorithm. One step is only a small part of it. Only present students add 1 to count, and count is what gets shown. So it counts students who are present. Variable names are clues. highScore only changes when a bigger score appears, so it stores the best score.

Common mistakes: The algorithm adds up prices, so line 2 should ASK price. It asks for cost, but line 3 uses price, so the total would never be worked out properly. The variable is called steps, not step. The purpose is to count 10 steps and show the answer, so line 4 should be SHOW steps.

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 106–119) and word search (Modules 106–132).

Take this worksheet further — free with Cloodit

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

Learning
Duo
An algorithm sets total to 0, adds each price to total, then SHOWS total. What is its purpose?
To work out the total cost of all the pricesTo count how many prices there are
Matches
Purpose: it uses a variable called total
↓
This only describes one part of the algorithm. A purpose says what the whole algorithm achieves, not just one step or variable.
Applying
Meanings
Term
purpose
Meaning
What the whole algorithm achieves. Follow the steps, check what it SHOWS and read the variable names for clues, then say it in one sentence.
Practice
SET total TO 0
Testing
Gaps
total
Check Answer
Spots
1SET total TO 0
2ASK cost

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

The 'Reindeer' badge — Dictionary Guide, 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. An algorithm sets total to 0, adds each price to total, then SHOWS total. What is its purpose?
A. To count how many prices there are
B. To work out the total cost of all the prices ✓
The SHOW step displays total, and total is built by adding every price. So the algorithm adds up prices.
2. What does the purpose of an algorithm tell us?
A. What the whole algorithm achieves ✓
B. What one single step does
Purpose is about the whole algorithm. One step is only a small part of it.
3. An algorithm sets count to 0, goes through each student, adds 1 to count if the student is present, then SHOWS count. Which sentence is its purpose?
A. It shows the name of every student.
B. It counts how many students are present. ✓
Only present students add 1 to count, and count is what gets shown. So it counts students who are present.
4. An algorithm uses variables named highScore and playerScore. If playerScore is bigger than highScore, it copies playerScore into highScore. What do the names hint at?
A. It keeps track of the highest score ✓
B. It adds up all the scores
Variable names are clues. highScore only changes when a bigger score appears, so it stores the best score.
5. An algorithm ends with: IF temperature < 15 THEN SHOW 'Take a jumper!'. What is the best purpose?
A. To tell someone if they need a jumper ✓
B. To measure the temperature
The SHOW step is a big clue. The message tells the user what to do about the weather.

Match the Pairs

SET total TO 0 REPEAT 5 TIMES ADD score TO total SHOW total → Purpose: adds up five scores and shows the total
IF temperature > 30 THEN SHOW "Wear a hat" ELSE SHOW "No hat needed" → Purpose: tells you whether to wear a hat
Variable names are clues to the purpose → SET lapsRun TO 0 REPEAT UNTIL lapsRun = 10 ADD 1 TO lapsRun SHOW lapsRun
The SHOW steps tell you what the algorithm achieves → IF age >= 18 THEN SHOW "You can vote" ELSE SHOW "Too young to vote"
Purpose: it uses a variable called total → This only describes one part of the algorithm. A purpose says what the whole algorithm achieves, not just one step or variable.
Purpose: SET count TO 0, then REPEAT 3 TIMES, then SHOW count → This just repeats the steps in order. It does not say what the algorithm achieves.

Key Term

purpose
What the whole algorithm achieves. Follow the steps, check what it SHOWS and read the variable names for clues, then say it in one sentence.

Fill in the Blanks

1. SET total ← 0 SET total ← total + 8 SHOW total
Hint: Type the keyword that displays a value. What an algorithm displays is a big clue to its purpose.
2. SET lives ← 3 IF lives = 0 THEN SHOW "Game over"
Hint: Type the variable name that the algorithm checks. Its name is a clue to what the algorithm is for.
3. SET cost ← 35 SET change ← 50 - cost SHOW change
Hint: Type the maths operator that works out the leftover money. Think about what the algorithm shows.
4. SET score ← 62 IF score >= 50 THEN SHOW "Pass" ELSE SHOW "Try again"
Hint: Type the keyword for the other path when the condition is not true. The two outputs show the purpose.
5. SET cheer ← "Hooray!" REPEAT 3 TIMES SHOW cheer
Hint: Type the keyword that makes the steps run again. The repeated output shows what the algorithm achieves.

Spot the Error

Question 1
A SET total TO 0
B ASK cost
C SET total TO total + price
D SHOW total
Line B — The algorithm adds up prices, so line 2 should ASK price. It asks for cost, but line 3 uses price, so the total would never be worked out properly.
Question 2
A SET steps TO 0
B REPEAT 10 TIMES
C SET steps TO steps + 1
D SHOW step
Line D — The variable is called steps, not step. The purpose is to count 10 steps and show the answer, so line 4 should be SHOW steps.
Question 3
A SET evens TO 0
B ASK number
C IF number MOD 2 = 1 THEN
D SET evens TO evens + 1
E SHOW evens
Line C — The variable name evens tells us the purpose is to count even numbers. An even number has a remainder of 0 when divided by 2, so the test should be MOD 2 = 0.
Question 4
A SET highest TO 0
B ASK score
C IF score < highest THEN
D SET highest TO score
E SHOW highest
Line C — The purpose is to find the highest score. The new score should replace highest only when it is bigger, so the test should be score > highest.
Question 5
A SET savings TO 0
B REPEAT 5 TIMES
C SET savings TO savings + 5
D SHOW "Money after 4 weeks"
Line B — The SHOW step says the money is after 4 weeks, so the loop should repeat 4 times, one for each week. Repeating 5 times does not match the purpose.

Student with a class code? Join your class →