Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This Predicting the outcome 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 | |
|---|---|---|
| 1trace table | AI predict: total will be 10. Now run it and compare. | |
| 2start with score = 3 | BThe table must show how the value changes after every step, not just the final value. | |
| 3Predict first, then check: work out the answer on paper, then run the algorithm to see if you were right | CA table where you write down the value of each variable after every step, so you can see how the values change | |
| 4Try different inputs: test the same algorithm with another starting value because the outcome might change | DThe prediction was guessed instead of traced. Following each repeat gives 2, 4, 6, so the output is 6. | |
| 5count = 0 REPEAT 3 TIMES count = count + 2 Output: count Prediction: 3 (guessed without tracing) | ETest 1: age = 8 Test 2: age = 14 | |
| 6Trace table: only wrote the final value of score, skipped the steps in between | FChoose a starting value to test, then follow each step from there to see what the algorithm shows at the end |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
trace — To trace an algorithm, pick starting values, follow each step in order, write down how the values change, and say what it shows at the end.SET total TO 4
ADD 3 TO total
SHOW total # it shows 7SET count TO 0
REPEAT 3 TIMES: ADD 2 TO count
SHOW count # it shows 6SET temp TO 20
IF temp > 25 THEN SHOW "Hot"
ELSE SHOW "Cool" # 20 > 25 is falseSET n TO 10
REPEAT UNTIL n < 5: SUBTRACT 3 FROM n
SHOW n # 10, 7, 4 so it shows 4SET a TO 3
SET b TO a * 2
SHOW b # table: a = 3, b = 6