Code
total = 0
repeat 5 times: total = total + 6
print(total)
Grade 9 · Math · Unit 9 of 15
Predict what the code does
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
Children can open this short lesson before they practise.
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
A taste of this unit. In the app, questions change every time and get easier or harder to match your child.
Question 1
What does this code print?
total = 0
repeat 5 times: total = total + 6
print(total)
answer box
30
Hint: The loop adds 6 a total of 5 times: 5 × 6 = 30.
Question 2
What does this code print?
n = 2
while n < 50: n = n * 3
print(n)
answer box
54
Hint: Keep multiplying by 3 until n is 50 or more. The last value is 54.
Question 3
What does this code print?
x = 12
if x > 8: print("big")
otherwise: print("small")
Tap an answer to try it.
Question 4
What does this code print?
define area(w, h): return w * h
print(area(2, 7))
answer box
14
Hint: area(2, 7) returns 2 × 7 = 14.
Question 5
What does this code print?
x = 12
print(x + 3 < 15)
Tap an answer to try it.
Question 6
What does this code print?
x = 4
y = 2 * x + 5
print(y)
answer box
13
Hint: x is 4, so y = 2 × 4 + 5 = 13.
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
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.