Study guide

5.3 Coding & Computational Thinking in Ontario Math

Ontario Mathematics Proficiency Test MPT

Track your progress as you read

Finished sections get a check mark.

1 Chapter 1: Introduction & Exam Overview

1.1 Ontario MPT Format, Scoring & Certification Requirements 1.2 The MPT Blueprint: Content Dimensions, Pedagogy Dimensions & Pacing

2 Chapter 2: Number Sense & Basic Operations

2.1 Whole Numbers, Place Value, Integers & Order of Operations 2.2 Prime Factors, Divisibility, GCF & LCM 2.3 Exponents, Powers & Scientific Notation

3 Chapter 3: Rational Numbers & Proportional Reasoning

3.1 Fractions: Types, Equivalencies & Operations 3.2 Decimals, Percents & Conversions 3.3 Ratios, Rates, Unit Rates & Proportions 3.4 Ordering & Comparing Whole Numbers, Integers, Decimals & Fractions

4 Chapter 4: Algebra, Patterning & Expressions

4.1 Patterning, Sequences & Functional Rules 4.2 Polynomial Terminology & Simplifying Algebraic Expressions 4.3 Solving Linear Equations & Inequalities

5 Chapter 5: Linear Relations & Computational Thinking

5.1 Linear Relations, Rate of Change & Slope 5.2 Direct vs. Partial Variations & Word Problems 5.3 Coding & Computational Thinking in Ontario Math 5.4 Solving Linear Systems Graphically

6 Chapter 6: Spatial Sense, Geometry & Measurement

6.1 Geometric Properties & Angle Relationships 6.2 Metric System & Unit Conversions 6.3 Perimeter & Area of 2D Polygons & Circles

7 Chapter 7: 3D Geometry, Pythagorean Theorem & Transformations

7.1 Surface Area & Volume of 3D Prisms & Cylinders 7.2 The Pythagorean Relationship & Right-Triangle Problems 7.3 Coordinate Plane & Geometric Transformations

8 Chapter 8: Data Management & Statistics

8.1 Data Collection, Organization & Sampling 8.2 Graphical Representations of Data 8.3 Measures of Central Tendency & Data Spread

9 Chapter 9: Probability

9.1 Simple Probability & Theoretical vs. Experimental 9.2 Compound Events, Tree Diagrams & Independence

10 Chapter 10: Financial Literacy

10.1 Money, Budgeting & Gross vs. Net Income 10.2 Sales Tax (HST), Discounts & Purchasing Power 10.3 Simple & Compound Interest & Borrowing Costs

11 Chapter 11: Mathematics Pedagogy & Assessment

11.1 Ontario Math Curriculum & Mathematical Processes 11.2 Instructional Frameworks: CPA & Three-Part Lesson 11.3 Assessment & Evaluation under Growing Success 11.4 Growing Success: Fundamental Principles & Learning Skills and Work Habits

12 Chapter 12: Inclusive Pedagogy & Differentiated Instruction

12.1 Universal Design for Learning (UDL) & Differentiated Instruction 12.2 Supporting English Language Learners & Diverse Learners 12.3 Cultivating Growth Mindset & Reducing Math Anxiety 12.4 Learning for All: Instructional Approaches, the Tiered Approach & Planning Assessment and Instruction

5.3 Coding & Computational Thinking in Ontario Math

Key Takeaways Explain This Topic AI

The 2020 Ontario Curriculum embeds coding in Strand C (Algebra) from Grades 1-9 to develop computational thinking and algorithmic problem solving.

The four pillars of computational thinking in math are decomposition, pattern recognition, abstraction, and algorithm design.

Essential coding constructs include sequential logic, conditional statements (IF-THEN-ELSE), and loops (FOR count-controlled, WHILE condition-controlled).

Execution tracing and debugging rely on trace tables to track variable states systematically and fix logical errors like off-by-one or initialization bugs.

Last updated: August 2026

5.3 Coding & Computational Thinking in Ontario Math

With the release of the revised 2020 Ontario Elementary Mathematics Curriculum (Grades 1–8) and the 2021 De-streamed Grade 9 Course (MTH1W), Coding and Computational Thinking were formally integrated into Strand C: Algebra . Knowing what coding looks like in the Ontario program matters for the MPT's pedagogy component: The Program in Mathematics and The Mathematical Processes are named sections of the Mathematics Curriculum Context dimension, and Strand C is where coding lives.

Scope note. Coding and computational thinking are not among EQAO's published fundamental knowledge and skills for the mathematics content component (Number Sense; Relationships and Proportional Reasoning; Measurement). Do not expect to trace pseudo-code for marks in Section 2 or Section 3. Study this section to understand the curriculum you will be asked about , and because tracing an algorithm is excellent practice for the multi-step arithmetic and linear-relations reasoning that the mathematics component genuinely does assess.

1. The Four Pillars of Computational Thinking in Math

Computational thinking is a problem-solving process that formulates mathematical tasks so that their solutions can be executed by a computer or systematic algorithm.

Loading diagram...

Decomposition: Breaking a complex mathematical problem into smaller, manageable sub-problems (e.g., separating total revenue calculation into calculating individual unit sales and applying discounts).

Pattern Recognition: Identifying trends, rules, or repeating structures in data or numerical sequences (e.g., discovering first differences in linear relations).

Abstraction: Stripping away non-essential details to focus on general mathematical formulas or algebraic logic (e.g., converting specific numeric steps into a general formula y = m x + b y = mx + b y = m x + b ).

Algorithm Design: Developing a step-by-step, ordered set of instructions (pseudo-code) to solve the problem systematically.

2. Core Programming Constructs in Pseudo-code

In Ontario classroom resources, algorithms are usually presented in language-agnostic pseudo-code . Understanding the fundamental control structures is what lets a teacher read, run, and repair student code.

A. Variables & Assignment

Assignment Operator ( SET or <- ): Stores a value in a variable.

Key Distinction: In algebra, x = x + 1 x = x + 1 x = x + 1 is an impossible equation. In programming, SET x = x + 1 takes the current stored value of x x x , adds 1, and overwrites x x x with the new result. SET total = 0

  • SET rate = 15.50
  • SET hours = 40
  • SET total = rate * hours
  • B. Sequential Logic

Instructions execute in exact sequential order from top to bottom, one line at a time.

C. Conditional Control Structures ( IF-THEN-ELSE )

Conditionals allow an algorithm to branch and execute different mathematical calculations based on whether a Boolean condition evaluates to TRUE or FALSE . IF hours > 40 THEN

  • SET overtimeHours = hours - 40
  • SET pay = (40 * rate) + (overtimeHours * rate * 1.5)
  • ELSE
  • SET pay = hours * rate
  • END IF
  • D. Looping Control Structures (Repetition)

Loops allow code blocks to execute repeatedly without duplicating lines.

  • Count-Controlled Loop ( FOR Loop): Executes a predetermined number of times. SET sum = 0
  • FOR i FROM 1 TO 5 DO
  • SET sum = sum + i
  • END FOR

Condition-Controlled Loop ( WHILE or REPEAT-UNTIL Loop): Executes continuously as long as a Boolean condition remains true (or until a condition becomes true). SET balance = 1000

  • SET month = 0
  • WHILE balance < 2000 DO
  • SET balance = balance * 1.05
  • SET month = month + 1
  • END WHILE
  • 3. Systematic Execution Tracing & Trace Tables

To trace pseudo-code accurately during an examination, construct a Trace Table . A trace table tracks line execution step-by-step alongside variable values and condition checks.

  • Example Trace Walkthrough
  • Consider the following algorithm designed to accumulate the sum of odd numbers: Line 1: SET sum = 0
  • Line 2: FOR k FROM 1 TO 4 DO
  • Line 3: SET oddNum = (2 * k) - 1
  • Line 4: SET sum = sum + oddNum
  • Line 5: END FOR
  • Line 6: PRINT sum

Executed Trace Table:

  • Line # Iteration ( k k k ) oddNum Calculation sum Value Condition / Notes
  • Line 1 — — 0 Initialize sum
  • Line 2 k = 1 k = 1 k = 1 — 0 Start Loop ( k = 1 k=1 k = 1 )
  • Line 3 k = 1 k = 1 k = 1 ( 2 × 1 ) − 1 = 1 (2 \times 1) - 1 = 1 ( 2 × 1 ) − 1 = 1 0 Compute odd number
  • Line 4 k = 1 k = 1 k = 1 1 0 + 1 = 1 0 + 1 = 1 0 + 1 = 1 Update sum
  • Line 2 k = 2 k = 2 k = 2 — 1 Next Loop ( k = 2 k=2 k = 2 )
  • Line 3 k = 2 k = 2 k = 2 ( 2 × 2 ) − 1 = 3 (2 \times 2) - 1 = 3 ( 2 × 2 ) − 1 = 3 1 Compute odd number
  • Line 4 k = 2 k = 2 k = 2 3 1 + 3 = 4 1 + 3 = 4 1 + 3 = 4 Update sum
  • Line 2 k = 3 k = 3 k = 3 — 4 Next Loop ( k = 3 k=3 k = 3 )
  • Line 3 k = 3 k = 3 k = 3 ( 2 × 3 ) − 1 = 5 (2 \times 3) - 1 = 5 ( 2 × 3 ) − 1 = 5 4 Compute odd number
  • Line 4 k = 3 k = 3 k = 3 5 4 + 5 = 9 4 + 5 = 9 4 + 5 = 9 Update sum
  • Line 2 k = 4 k = 4 k = 4 — 9 Final Loop ( k = 4 k=4 k = 4 )
  • Line 3 k = 4 k = 4 k = 4 ( 2 × 4 ) − 1 = 7 (2 \times 4) - 1 = 7 ( 2 × 4 ) − 1 = 7 9 Compute odd number
  • Line 4 k = 4 k = 4 k = 4 7 9 + 7 = 16 9 + 7 = 16 9 + 7 = 16 Update sum
  • Line 6 — — 16 Output Printed: 16
  • 4. Debugging Common Mathematical Algorithm Errors

Debugging —identifying and correcting errors in mathematical algorithms—is an expectation of Strand C in the Ontario curriculum, and knowing the common failure modes helps you reason about the curriculum in pedagogy scenarios.

Common Algorithm Errors

Off-by-One Errors: Loop bounds execute one too many or one too few times (e.g., FOR i FROM 1 TO N-1 instead of 1 TO N ).

Incorrect Initializer Values: Setting accumulators to the wrong starting value.

For addition/summation: Initialize to 0 ( SET sum = 0 ).

For multiplication/factorials: Initialize to 1 ( SET product = 1 ). Initializing to 0 causes all future products to equal 0.

Infinite Loops: Forgetting to update the control variable inside a WHILE loop (e.g., failing to increment counter = counter + 1 ).

Inverted Logic Operators: Using < instead of > or failing to include equality ( >= ).

  • 5. Step-by-Step Worked Examples
  • Worked Example 1: Execution Trace of a Conditional Loop
  • Problem: Determine the final printed output of the following pseudo-code algorithm: SET count = 0
  • SET total = 50
  • WHILE total > 15 DO
  • IF total MOD 2 == 0 THEN
  • SET total = total - 10
  • ELSE
  • SET total = total - 5
  • END IF
  • SET count = count + 1
  • END WHILE
  • PRINT count

(Note: MOD computes the remainder after integer division).

Solution:

Iteration 1: total = 50 . Condition total > 15 is TRUE . 50 MOD 2 == 0 is TRUE (even). total becomes 50 − 10 = 40 50 - 10 = 40 50 − 10 = 40 . count becomes 0 + 1 = 1 0 + 1 = 1 0 + 1 = 1 .

Iteration 2: total = 40 . Condition total > 15 is TRUE . 40 MOD 2 == 0 is TRUE (even). total becomes 40 − 10 = 30 40 - 10 = 30 40 − 10 = 30 . count becomes 1 + 1 = 2 1 + 1 = 2 1 + 1 = 2 .

Iteration 3: total = 30 . Condition total > 15 is TRUE . 30 MOD 2 == 0 is TRUE (even). total becomes 30 − 10 = 20 30 - 10 = 20 30 − 10 = 20 . count becomes 2 + 1 = 3 2 + 1 = 3 2 + 1 = 3 .

Iteration 4: total = 20 . Condition total > 15 is TRUE . 20 MOD 2 == 0 is TRUE (even). total becomes 20 − 10 = 10 20 - 10 = 10 20 − 10 = 10 . count becomes 3 + 1 = 4 3 + 1 = 4 3 + 1 = 4 .

Loop Termination Check: total = 10 . Condition 10 > 15 is FALSE . The loop terminates. Final Printed Value: count = 4 .

6. Pedagogical Note for Ontario Classrooms

In Ontario schools, teachers connect block-based platforms (such as Scratch or Lynx) to math concepts. For instance, creating scripts to draw regular polygons requires computing interior/exterior angles ( 360 ∘ / n 360^{\circ} / n 36 0 ∘ / n ), directly combining geometry with loop controls.