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

Think, then code

Week 14 · Unit 6: Be a storyteller · 3 lessons
2

From steps to blocks

Computing 3: Unit 6, pp. 93–104
GoalTurn each line of an algorithm into one Scratch block.
New words
algorithm · a list of steps that solves a problem or does a jobhat block · a block that starts a script when something happensscript · a stack of blocks that a sprite follows
Explanation

A good way to make a program is to write the algorithm first, as a table of steps. Then you change each line into one block. The line that says what starts the program becomes a hat block from the Events group. A line about moving becomes a Motion block. A line about saying or changing costume becomes a Looks block. A line about waiting becomes a Control block. Snap the blocks together in the same order as the lines. At the end, check each block against its line.

whenclickedgo to x:-150y:-60sayTime to rest!for2secondsglide3secs to x:100y:-60next costume
Worked examples
StepInstruction
1When the green flag is clicked
2Go to x: −150, y: −60
3Say “Time to rest!” for 2 seconds
4Glide for 3 seconds to x: 100, y: −60
5Switch to the next costume
A hen has to walk to a nest and sit down. Here is the algorithm for the hen. The nest is a static object and has no code.
x 240−240y 180−180hen startnest
Here is the stage. The hen starts on the left and glides to the nest on the right. The nest stays where it is.
LineBlockGroup
1when ⚑ clickedEvents
2go to x: −150 y: −60Motion
3say Time to rest! for 2 secondsLooks
4glide 3 secs to x: 100 y: −60Motion
5next costumeLooks
Each line becomes one block, and each block comes from a group.
Class activity

Block cards (with a friend): write the lines of an algorithm for a fish on separate cards: “When the green flag is clicked”, “Go to x: −100, y: 0”, “Wait 1 second”, “Say Bubbles! for 2 seconds”, “Glide for 2 seconds to x: 100, y: 0”. Next to each one, write the Scratch block it becomes and its group. Lay the second row of cards under the first. Does every line have a block? If you have a computer or tablet, build the program in Scratch and click the flag.

Practice
1
Write the block for each step. (a) Wait 2 seconds. (b) Say “Good morning!” for 3 seconds. (c) Go to x: 0, y: 50. (d) Switch to the next costume.
2
Write the algorithm as a table of steps for this program.
whenclickedgo to x:-100y:0sayHello!for2secondswait1secondsglide2secs to x:100y:0
3
The algorithm says: 1 When the green flag is clicked. 2 Go to x: −80, y: 20. 3 Wait 1 second. 4 Glide for 2 seconds to x: 120, y: 20. One block is wrong. Which one, and how do you fix it?
whenclickedgo to x:-80y:20wait1secondsglide1secs to x:120y:20
4
Which group of blocks do these come from? wait (1) seconds · say [Hi!] for (2) seconds · when green flag clicked · glide (2) secs to x: (0) y: (0)