Langkau ke kandungan

    Code Cove

    Reading Code Umur 8–10

    Read short programs with variables, loops and if–else, follow them line by line and predict exactly what they will do.

    • Umur 8–10
    • 3 misi
    • Permulaan → Semakin mahir → Cabaran

    Before you can write good code, you have to be able to read it. At Code Cove, Year 4 coders become the computer: they follow short programs one line at a time and predict exactly what will happen.

    Apa yang akan dipelajari anak anda

    • Follow a program from top to bottom, one line at a time
    • Keep track of a variable as it is set and changed
    • Work out how many times the lines inside a loop run
    • Decide which branch of an if–else runs

    Be the computer

    A computer never guesses and never skips ahead. To trace a program, do the same: point at each line, do what it says, and write down the value of every variable as it changes.

    Indents matter

    Lines tucked in under “repeat” or “if” belong to it. A line that is not tucked in comes after the loop has finished, so it runs only once. Spotting where a loop ends is one of the most useful reading skills.

    Contoh soalan

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

    1. 1. In what order does a computer run the lines of a program?

      • In a random order
      • All at once
      • From top to bottom, one at a time
      • From bottom to top
      Tunjuk jawapan

      Jawapan: From top to bottom, one at a time. A program runs line by line from the top, unless a loop or an “if” changes the path.

    2. 2. What is said last?

      • Ready
      • Nothing
      • Steady
      • Go
      Tunjuk jawapan

      Jawapan: Go. Lines run from top to bottom, so “Go” comes last.

    3. 3. What is lives at the end?

      • 1
      • 2
      • 4
      • 3
      Tunjuk jawapan

      Jawapan: 2. Lives starts at 3 and goes down by 1: 3 − 1 = 2.

    4. 4. Match each line of code to what it does.

      • repeat 3
      • x = 2 + 3
      • print("hi")
      • shows hi
      • x becomes 5
      • does it three times
      Tunjuk jawapan

      Jawapan: print("hi") → shows hi · repeat 3 → does it three times · x = 2 + 3 → x becomes 5. Reading code carefully tells you what it will do.

    Tip untuk orang dewasa

    • Trace on paper: one column for each variable, one row for each line that runs.
    • Cover the answers and say your prediction aloud before looking.
    • Try the same programs in Scratch and see whether your prediction was right.