- set stars to 0repeat 3 timesadd 1 to starssay stars
Add 1, again and again
Add 1 to stars sits inside a repeat 3. The loop goes round three times. So the box ends at 3.
- set stars to 0repeat 4 timesmove rightcollect the staradd 1 to starssay stars
Count while you collect
Each time round, the robot moves, collects a star and adds 1. Four stars, so it says 4.
- set stars to 0repeat 4 timesmove rightif on a starcollect the staradd 1 to starssay stars
Count only the stars
Now add 1 sits inside an if block. The robot only counts when it finds a star. Two stars, so it says 2.
- repeat 3 timesset stars to 0add 1 to starssay stars
Set to 0 before the loop
Here set stars to 0 is inside the loop. It empties the box each time round. So the robot only says 1.
Say after the loop
Put say stars after the loop, not inside. Then the robot waits until all the counting is done.
For parents
Goal: Your child learns to put add 1 inside a repeat so the counting box goes up each time the loop goes round, with set to 0 before the loop and say after it.
- Ask: how many times does the loop go round? That is often the answer.
- Have your child keep a tally on paper while the robot runs.
- Talk about where each block lives: before the loop, inside it, or after it.
Away from the screen: Do jumping jacks together. Before you start, set the count to 0. Each jump, add 1 out loud. When you stop, your child says the final number.