Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This Working out the purpose of an algorithm worksheet is part of the ACARA Digital Technologies Years 5–6 — Algorithms with Branching and Repetition journey. Print it as a booklet?
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1SET total TO 0 REPEAT 5 TIMES ADD score TO total SHOW total | AThis only describes one part of the algorithm. A purpose says what the whole algorithm achieves, not just one step or variable. | |
| 2IF temperature > 30 THEN SHOW "Wear a hat" ELSE SHOW "No hat needed" | BIF age >= 18 THEN SHOW "You can vote" ELSE SHOW "Too young to vote" | |
| 3Variable names are clues to the purpose | CSET lapsRun TO 0 REPEAT UNTIL lapsRun = 10 ADD 1 TO lapsRun SHOW lapsRun | |
| 4The SHOW steps tell you what the algorithm achieves | DThis just repeats the steps in order. It does not say what the algorithm achieves. | |
| 5Purpose: it uses a variable called total | EPurpose: tells you whether to wear a hat | |
| 6Purpose: SET count TO 0, then REPEAT 3 TIMES, then SHOW count | FPurpose: adds up five scores and shows the total |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
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.SET total ← 0
SET total ← total + 8
SHOW totalSET lives ← 3
IF lives = 0 THEN
SHOW "Game over"SET cost ← 35
SET change ← 50 - cost
SHOW changeSET score ← 62
IF score >= 50 THEN SHOW "Pass"
ELSE SHOW "Try again"SET cheer ← "Hooray!"
REPEAT 3 TIMES
SHOW cheer