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. How many times does the loop run?

      • 5
      • 1
      • 4
      • 6
      Tunjuk jawapan

      Jawapan: 5. Count goes up by 1 each time, from 0 to 5: five rounds.

    2. 2. What is x when the loop stops?

      • 0
      • 4
      • 3
      • 2
      Tunjuk jawapan

      Jawapan: 3. x goes 1, 2, 3 — and at 3 the condition is true, so the loop stops.

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

      • 4
      • 0
      • 2
      • 3
      Tunjuk jawapan

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

    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.