3
Predict a story program
Computing 2: Unit 10, pp. 134–148
GoalPredict what a ScratchJr program will do before you run it, and then check.
New words
scene · one part of a storyoutput · what the program does and saysrun · to start a program
Explanation
A program is an algorithm too. Its input can be a tap or the green flag. Its output is what the characters do and say. Before you run a program, read each block and predict the output. Then run it and watch. If the output is not what you predicted, look at the blocks again.
Worked examples
Predict: the character goes up 2, says “Look!” and then goes down 2. It ends where it started.
Both characters start on the green flag, so they move at the same time. The bunny moves right 5 and the turtle moves right 1. The bunny gets much farther.
A wrong prediction is useful. It shows that we made a mistake when we read the blocks, or that the program has a bug.
Class activity
Act it out: draw three short programs on cards, for example “start on green flag, right 2, hop 1, say Hi!”. Mark a grid on the floor with chalk or tape. A friend predicts what you will do. Then you act out the cards on the grid: one step for each number. Score a point for each right prediction.
Practice
1
What will the character do, in order?
It moves right 4, makes a quarter turn left, and says “Hi!”.
2
Where does the character finish compared with where it started?
Back at the start: it goes up 3 and then down 3.
3
Which character moves when you press the green flag?
The Fish. The Bird starts on tap.
4
A character moves right 2, then up 1, then left 2. Where does it end compared with the start?
One square above the start.