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

Repeat blocks

Week 10 · Unit 4: Be an animator · 3 lessons
3

Programs that repeat

Computing 2: Unit 4, pp. 54–65
GoalPlan and read programs that use repeat and forever blocks, and find a bug in a longer algorithm.
New words
animation · pictures shown one after another so that something seems to moveforever · a block that repeats the blocks for ever, until you stop the programproject · a bigger program that you plan and make
Explanation

An animation shows pictures one after another, so something seems to move. Repeat blocks help us to make animations without writing the same blocks again and again. A forever block repeats until you stop the program. First plan the algorithm in steps. Then write the program and use a repeat block where something happens more than once. Last, test it and look for bugs.

Frame 1Frame 2Frame 3
Worked examples
113Big!
Algorithm: start on the green flag, repeat 3 times: hop 1 and grow, then say Big!, stop. The character hops and grows 3 times. Then it says Big! once.
A maze has a bug. The path goes up 1, right 3, up 2, right 2. The algorithm says: up 1, right 3, up 3, right 2. Step 3 has the bug. It must be up 2, not up 3.
22
A bouncing ball goes up 2 and down 2 for ever. The last block is a forever block. The program never ends until we stop it.
Class activity

Flipbook: cut 8 small pieces of paper and staple them together on one side. Draw a ball on the bottom of the first page, a little higher on the next page and so on, then back down. Flip the pages quickly with your thumb. That is an animation. Then write an algorithm for your own animation, such as “repeat 3: ball goes up 2, ball goes down 2”. Last, write an algorithm for skipping with a rope that uses a repeat, such as “repeat 10: jump”.

Practice
1
How many pop sounds are played, and how far does the character move?
32
2
Which block makes a program repeat for ever?
11
3
The maze algorithm says: right 1, up 3, right 4. Which step has the bug and what must it be?
4
Write an algorithm for watering 4 plants in a row that uses one repeat.