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

Term 1 review

Week 11 · Review: Term 1 · 3 lessons
1

Programs, resets and timing

Computing 3: Units 1–4, pp. 8–78
GoalReview following and fixing algorithms, making programs concise, resetting sprites and running scripts together.
New words
trace · to follow a program step by step and write down what happensreset · to put a sprite back to its start place or sizeefficient · doing the job with the fewest steps
Explanation

An algorithm is a list of steps in the right order. We follow it one step at a time to see where it leads. If it goes wrong, we find the wrong step, edit it and test again. An efficient algorithm uses the fewest steps. We join moves that are the same and side by side, and we use a repeat for steps that happen again and again. In Scratch, go to and set size blocks right after the hat reset a sprite. Scripts that start with the same event run together, so we check how long each one takes.

IdeaWhat we do
followdo each step in order
fixfind the wrong step, edit it, test again
shortenjoin same side-by-side steps, use repeat
resetgo to and set size after the hat
timingadd the waits and glides; add a wait to match
Worked examples
The robot starts at the bottom-right facing up. Algorithm: Move 2 forward. Turn left. Move 2 forward. Turn right. Move 1 forward. It goes up 2, faces left, goes 2 along, faces up again and moves 1 more. It ends at the top, in the third column.
Longwhenclickedchange x by15change x by15change x by15change x by15Shortwhenclickedchange x by60
This program has 5 blocks. The four “change x by (15)” blocks are side by side, so they become one block “change x by (60)”. The new program has 2 blocks. It moves the sprite to the same place.
Awhenspacekey pressedwait1secondsglide1secs to x:100y:0Bwhenspacekey pressedglide2secs to x:-100y:0
Script A waits 1 second and then glides for 1 second: 2 seconds in all. Script B glides for 2 seconds. Both take 2 seconds, so they finish together.
Class activity

Programmer’s checklist (with a friend): make a checklist on a card with five questions, such as “Did I follow every step?”, “Is there a wrong step?”, “Can I join steps?”, “Did I reset?”, “Do my scripts finish together?” Write a short robot algorithm with one mistake, swap with your friend, and use the checklist to find and fix the mistake.

Practice
1
The robot starts at the bottom-left facing up. Algorithm: Move 2 forward. Turn right. Move 3 forward. Turn left. Move 1 forward. Where does it finish: the flag, the tree or the star?
flagtreestar
2
Make this program more concise. How many blocks does your new program have?
whenclickedmove15stepsmove15stepswait1secondsmove15stepsmove15steps
3
A sprite starts at size 100. Each run does this program. What size is it after 3 runs with no reset? What block would fix the problem?
whenclickedchange size by-10
4
Script A takes 3 seconds and script B takes 2 seconds. They start together. Which finishes first, and what should be added to B?
Awhenspacekey pressedwait2secondssayHi!for1secondsBwhenspacekey pressedglide2secs to x:100y:0