A loop tells a computer to repeat something. Instead of writing “move right, move right, move right”, a programmer writes “repeat 3: move right”. Year 1 coders read short loops and work out what the robot does.
Apa yang akan dipelajari anak anda
- Know that a loop repeats instructions
- Work out how many steps a simple loop makes
- Choose the loop that matches a list of repeated moves
Less code, same job
Loops save time and make programs easier to read. They also make changes easy: to take five steps instead of three, you only change one number.
Contoh soalan
Berikut ialah beberapa soalan seperti dalam misi pertama. Bolehkah anda menjawabnya?
1. True or false? The robot moves 1 squares.
Tunjuk jawapan
Jawapan: Salah. The loop repeats "move →" 2 times, so the robot moves 2 squares.
2. How many squares does the robot move?
- 2
- 5
- 4
- 3
Tunjuk jawapan
Jawapan: 2. The loop repeats "move →" 2 times, so the robot moves 2 squares.
3. True or false? The robot moves 7 squares.
Tunjuk jawapan
Jawapan: Salah. The loop repeats "move ↑" 2 times, so the robot moves 2 squares.
Tip untuk orang dewasa
- Play a “repeat” game: “Repeat 4: clap, stamp!”
- Spot loops in songs with repeating choruses.