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

Paths and projects

Week 3 · Unit 1: Be a game developer · 3 lessons
2

Trace a longer program

Computing 2: Unit 1, pp. 8–23
GoalTrace a longer program block by block and say what the character does.
New words
trace · to follow a program step by step to see what it doeshop · to jump up and downsequence · blocks that run one after the other
Explanation

A longer program is still steps in order. Read it from left to right. Do one block at a time. This is called tracing. Write down what happens after each block. After the last block you know the result. Tracing helps you find mistakes before you run the program.

312Yes!start ongreen flagmoverightmoveuphopsayend
Worked examples
After blockAcrossUp
start00
up 202
right 332
up 133
Trace: start on the square with 0 across and 0 up. The blocks are up 2, right 3, up 1. The table shows where the character is after each block.
4Hi!6start ontapmoverightsayturnleftend
This program moves, says “Hi!” and then makes a half turn. The character does the things in that order.
The order matters. Hop and then say is not the same as say and then hop. The character does the first block first.
Class activity

Act out a trace (two or three players): write five cards: take 3 steps forward, hop 2 times, spin right 12 (turn around once), clap 2 times, say “Yes!”. One player turns over one card at a time and does it. Another player draws a tick for each card on a list. Then shuffle the cards and trace the new order. How is the result different?

Practice
1
The character starts at 0 across and 0 up. It runs: right 2, up 3, right 1. Where does it finish?
231
2
The character should make a quarter turn to the right after it moves right. Which block is missing?
2?1
3
The algorithm says: say Hello, then move right 5. Which two blocks should swap places?
5Hello
4
How many blocks does this program have: start on tap, hop 2, spin right 6, say “Hi!”, stop?