GradeMap

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

Sample 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 8 times: total = total + 5

    print(total)

    answer box

    Show answer

    40

    Hint: The loop adds 5 a total of 8 times: 8 × 5 = 40.

  2. Question 2

    What does this code print?

    Code

    x = 3

    y = 5 * x + 7

    print(y)

    answer box

    Show answer

    22

    Hint: x is 3, so y = 5 × 3 + 7 = 22.

  3. Question 3

    Which line of code stores the cost of n tickets that cost $17 each?

    • cost = 17 * n
    • cost = n / 17
    • 17 = cost * n
    • cost = 17 + n
    Show answer

    cost = 17 * n

    Hint: Cost is the price times the number of tickets. The variable being created goes on the left of the equals sign.

  4. Question 4

    What does this code print?

    Code

    x = 11

    print(x + 4 < 15)

    • true
    • An error
    • false
    Show answer

    false

    Hint: 11 + 4 = 15, and 15 < 15 is false.

  5. Question 5

    What does this code print?

    Code

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

    print(area(3, 9))

    answer box

    Show answer

    27

    Hint: area(3, 9) returns 3 × 9 = 27.

  6. Question 6

    What does this code print?

    Code

    x = 19

    if x > 15: print("big")

    otherwise: print("small")

    • big
    • small
    • Nothing is printed
    Show answer

    big

    Hint: 19 > 15 is true, so the code prints "big".