the question what you do You use if every day
If it rains, you take an umbrella. If it is sunny, you leave it home. You check first, then you act.
- move rightif on a starcollect the starmove right
The if block
The robot moves, then asks: am I on a star? Yes! So it does the block inside the if. It collects the star.
- repeat 4 timesmove rightif on a starcollect the star
If the answer is no
When the answer is no, the robot skips the blocks inside. Watch the robot walk past the empty squares.
- repeat 4 timesmove rightif on a starcollect the star
One program, many boards
Here is the same program on a new board. The stars moved, but it still works. The if block checks every square.
For parents
Goal: Your child learns that an if block asks a yes or no question, and the robot only does the blocks inside when the answer is yes.
- Use the words if and then in daily talk: if your hands are dirty, then wash them.
- When the robot runs, ask at each square: is the answer yes or no here?
- Point out that the same program works on a new board because the if block checks for itself.
Away from the screen: Play a clapping game. Say: if I hold up a red thing, clap. Hold up different things. Your child claps only when the answer is yes. Then let your child make the rule.
Coding · Making Choices