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. It is raining. What does the program say?

      • Both messages
      • Nothing
      • Wear a hat
      • Take an umbrella
      Tunjuk jawapan

      Jawapan: Take an umbrella. The condition is true, so the first branch runs.

    2. 2. What does this program say?

      • 10
      • 6
      • 4
      • 46
      Tunjuk jawapan

      Jawapan: 6. Setting x again replaces the old value, so x is 6.

    3. 3. 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.

    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.