AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Term 3 review

Week 30 · Review: Term 3 · 3 lessons
2

Stories, tests and bugs

Computing 2: Units 9–11, pp. 122–163
GoalRemember how to predict the output, build in parts, test and debug.
New words
output · the result an algorithm givesbug · a mistake in a programtest · to run a program to see if it works
Explanation

An algorithm can take an input and give an output. We predict the output by doing each step in order. We build a program in small parts and test each part. If a program does not match its algorithm, it has a bug. We compare, find the block that is different, fix one bug and test again. Characters can send and receive messages, and the colours must match.

Worked examples
After stepNumber
enter the number3
add 47
double14
take away 59
The input is 3. The steps are: add 4, double, take away 5. The number goes 3, 7, 14, 9. The output is 9.
2Oh!
The algorithm is: start on bump, move left 2, say “Oh!”, stop. The red outline shows the bug: the move block goes right. Change it to left 2.
sends greenstarts on green
The frog sends a green message. The duck starts on a green message. The colours match, so the duck starts when the frog finishes.
Class activity

Predict and check relay (three players): player 1 chooses an input number and writes an algorithm of three steps. Player 2 predicts the output on paper. Player 3 checks with counters. Was the prediction right? If not, find the step with the mistake. Swap roles and play again.

Practice
1
The input is 2. The steps are: double, add 5, take away 3. What is the output?
2
The algorithm is: start on tap, move down 2, hop 3, stop. Which block has a bug and how do you fix it?
22
3
The cat sends a blue message, but the mouse never starts. The mouse starts on a red message. What is the fix?
4
Why do we test each part of a program as we write it?