Grade 9 · Math · Unit 9 of 15

Code Reader

Predict what the code does

What your child practises

Reading short programs with variables, loops, if statements and functions, predicting the output, and changing a parameter to get a new result. No typing is needed; the code is written in plain pseudocode.

Ontario Curriculum expectation: C2.1, C2.2, C2.3 · reading and altering code with variables, equations and inequalities

How we explain it

Children can open this short lesson before they practise.

  1. A variable stores a number that can change.
  2. Run the code one line at a time and track the values.
  3. A condition, like x > 5, is true or false.

Example: x = 4. Then x = x + 3. Then x = x × 2. What is x? After line 2: 4 + 3 = 7. After line 3: 7 × 2 = 14. Answer: 14

Try a few questions

A taste of this unit. In the app, questions change every time and get easier or harder to match your child.

  1. Question 1

    What does this code print?

    Code

    total = 0

    repeat 5 times: total = total + 6

    print(total)

    answer box

  2. Question 2

    What does this code print?

    Code

    n = 2

    while n < 50: n = n * 3

    print(n)

    answer box

  3. Question 3

    What does this code print?

    Code

    x = 12

    if x > 8: print("big")

    otherwise: print("small")

    Tap an answer to try it.

  4. Question 4

    What does this code print?

    Code

    define area(w, h): return w * h

    print(area(2, 7))

    answer box

  5. Question 5

    What does this code print?

    Code

    x = 12

    print(x + 3 < 15)

    Tap an answer to try it.

  6. Question 6

    What does this code print?

    Code

    x = 4

    y = 2 * x + 5

    print(y)

    answer box

Code Reader in Ontario

In the Ontario Curriculum, this is unit 9 of 15 in Grade 9 Math, after Multi-Step Equations and before Linear Relations.

Gradelings describes a child's practice on this unit as Level 1, Level 2, Level 3 or Level 4 (Four levels of achievement). That reflects practice, not a report-card mark: the teacher decides the mark.

Source: Ontario Ministry of Education, Curriculum and Resources

All Grade 9 Math units in Ontario

Ready to try Gradelings?

Curriculum-matched practice for Pre-K to Grade 9 across Canada and the US, with kind hints, learning games and no ads. Try everything free for 14 days with no card, then subscribe if it helps.