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

Counting loops

Week 8 · Unit 4: Be a storyteller · 3 lessons
2

How many times?

Computing 4: Unit 4, pp. 48–61
GoalWork out how many times steps are repeated from an algorithm.
New words
trace · to follow an algorithm one step at a timetotal · all of something added togetherstep · one instruction in an algorithm
Explanation

Read a repeat step carefully. “Repeat steps 3 and 4 three more times” means the steps have been done once already, and then three more times. So they are done 1 + 3 = 4 times in all. To avoid mix-ups, a good algorithm can say the total: “Do steps 3 and 4 four times in all.” To find how many times an action happens, count the iterations, then multiply by the number of times the action appears in one iteration. A table helps you keep count. To trace an algorithm means to follow it one step at a time and write down what happens.

StepInstruction
1Start
2Dig a hole
3Drop in one seed
4Cover the seed
5Repeat steps 2 to 4 five more times
6Stop
Worked examples
Time roundSeeds planted so far
11
22
33
44
55
66
Trace the seed algorithm in the picture above. Steps 2 to 4 are done once, then five more times, so six times in all. Six seeds are planted.
SentenceTimes in all
Repeat steps 2 and 3 four more times1 + 4 = 5
Do steps 2 and 3 four times in all4
These two sentences are not the same. “More” means extra times after the first time.
FruitIn one iterationIn 5 iterations
apple210
pear15
When an iteration has more than one of an action, multiply. Each iteration puts 2 apples and 1 pear in a box. Five iterations give 5 × 2 = 10 apples and 5 × 1 = 5 pears.
Class activity

Pebble tracing (with family): follow this algorithm. 1 Put a pebble in a bowl. 2 Clap twice. 3 Repeat steps 1 and 2 five more times. Count the pebbles in the bowl and the claps you made. Write down your guess before you start. Then make your own algorithm with “more times” and let a partner guess the totals before doing it.

Practice
1
How many hops and how many spins does this algorithm make?
StepInstruction
1Start
2Hop on one foot
3Spin once
4Repeat steps 2 and 3 two more times
5Stop
2
“Repeat steps 2 to 4 six more times.” How many times are steps 2 to 4 done in all?
3
Each iteration has 3 jumps and 1 clap. There are 5 iterations. How many jumps and claps in all?
4
How many plants are watered and how many steps are walked in this algorithm?
StepInstruction
1Start
2Water one plant
3Walk 2 steps
4Repeat steps 2 and 3 four more times
5Stop