Langkau ke kandungan

    Until Island

    Repeat Until Umur 9–11

    Meet loops that don’t count: “repeat until” stops when a condition comes true, and “forever” never stops at all.

    • Umur 9–11
    • 3 misi
    • Permulaan → Semakin mahir → Cabaran

    A “repeat 10” loop counts. But often we don’t know how many repeats we need: keep asking until the password is right; keep moving until you touch the wall. For that, coders use a loop with a stopping condition.

    Apa yang akan dipelajari anak anda

    • Know that “repeat until” stops when its condition becomes true
    • Know that a “forever” loop never stops by itself
    • Trace a variable through a loop to find when it stops
    • Spot a loop that can never end

    Check, then repeat

    A “repeat until” loop checks its condition before each round. If the condition is already true, the loop doesn’t run at all. If nothing inside the loop ever changes the condition, it will run forever.

    Skipping past the finish

    A classic bug: “repeat until x = 0” while x goes 5, 3, 1, −1… It jumps straight past 0, so the loop never ends. Using “x < 1” instead catches it. Text languages write the same idea the other way round, as “while x > 0”.

    Contoh soalan

    Berikut ialah beberapa soalan seperti dalam misi pertama. Bolehkah anda menjawabnya?

    1. 1. A “repeat until” loop keeps going until…

      • its condition becomes true
      • the computer is switched off
      • it has run 10 times
      • its condition becomes false
      Tunjuk jawapan

      Jawapan: its condition becomes true. The loop stops as soon as the condition is true.

    2. 2. How many times does the loop run?

      • 4
      • 0
      • 2
      • 3
      Tunjuk jawapan

      Jawapan: 3. Lives goes 2, 1, 0 — three rounds.

    3. 3. What does a “forever” loop do?

      • Runs ten times
      • Repeats without ever stopping by itself
      • Runs exactly once
      • Never runs
      Tunjuk jawapan

      Jawapan: Repeats without ever stopping by itself. It only ends when the whole program is stopped.

    4. 4. Match each loop to how it behaves.

      • forever
      • repeat until score = 10
      • repeat 10
      • stops when you reach 10
      • runs exactly 10 times
      • never stops
      Tunjuk jawapan

      Jawapan: forever → never stops · repeat 10 → runs exactly 10 times · repeat until score = 10 → stops when you reach 10. Repeat-until loops check a condition each time.

    Tip untuk orang dewasa

    • Act out a loop: “clap until I say stop” versus “clap five times”.
    • Trace loops with a table: write the variable’s value after every round.
    • In Scratch, try “repeat until touching edge” and watch when it stops.