Ontario coding curriculum · Grade 4
Grade 4 coding in the Ontario curriculum
What the Grade 4 math coding expectations ask for, what they mean in plain words, and a free nested-loop activity you can run in your next math period.
The two Grade 4 coding expectations
Coding sits in the Algebra strand of the Ontario Grades 1–8 Mathematics curriculum (2020), under overall expectation C3. In Grade 4, students are expected to:
C3.1 “solve problems and create computational representations of mathematical situations by writing and executing code, including code that involves sequential, concurrent, repeating, and nested events”
C3.2 “read and alter existing code, including code that involves sequential, concurrent, repeating, and nested events, and describe how changes to the code affect the outcomes”
Read the official Grade 4 C3 Coding page on Ontario.caIn plain words: students write code and run it (C3.1), and they read code someone else wrote, change it and explain what the change did (C3.2). Both include the four kinds of events below. Only nested events are new this year.
The four kinds of events, explained
Sequential events
Instructions run one after another, in order. (From Grade 1.)
Concurrent events
Two or more things happen at the same time, such as two sprites moving at once. (From Grade 2.)
Repeating events
A loop runs the same instructions several times. (From Grade 3.)
Nested events
One loop sits inside another loop. This is the new idea in Grade 4.
A nested loop is easiest to see in a drawing. One loop draws a square: four sides, four turns. Put that loop inside a second loop that repeats the square and turns a little each time, and you get a flower pattern. Students can see the inner loop and the outer loop doing different jobs.
What a Grade 4 student should be able to do
- Write a program that uses a loop inside a loop to draw or build a pattern
- Explain what the inner loop does and what the outer loop does
- Predict how a drawing changes when a number in the code changes, then test it
- Find and fix a mistake in someone else's code (debugging is part of C3.2)
- Rewrite long, repetitive code as a shorter loop
Where teachers get stuck
- “I've never coded.” Most Grade 4 teachers weren't trained in coding. Block-based tools help, but planning still takes time.
- Nested loops confuse students who can't yet tell which loop runs first. Start unplugged, so they act out the inner loop with their bodies before they code it.
- C3.2 gets skipped. Classes write code but rarely read and change someone else's. Build in a “predict, change, test” step every time.
- Devices and time. Shared Chromebooks and a busy timetable make a weekly coding block hard to protect.
Free activity: the nested-loop flower
One period, 45 to 60 minutes. Covers C3.1 and C3.2. Works in Scratch (free, in the browser) with the Pen extension.
1. Unplugged warm-up (10 minutes)
One student is the “robot”. The class gives the instructions: “Repeat 4 times: take 2 steps, turn right.” The robot walks a square. Then ask: “How do we make the robot walk that square 3 times, turning a little between squares?” Students discover they need a loop around the loop.
2. Code one square (10 minutes)
In Scratch, add the Pen extension, then build:
when green flag clicked
erase all
pen down
repeat 4
move 80 steps
turn right 90 degreesRun it. The sprite draws a square. That's a repeating event.
3. Nest it (10–15 minutes)
Wrap the square loop inside a second loop:
when green flag clicked
erase all
pen down
repeat 8
repeat 4
move 80 steps
turn right 90 degrees
turn right 45 degreesRun it. The sprite draws 8 squares, each turned 45 degrees from the last, making a flower. The inner loop draws one square. The outer loop repeats the square and turns. Eight turns of 45 degrees make a full circle (8 × 45 = 360).
4. Predict, change, test: the C3.2 part (10–15 minutes)
Before each change, students write down what they think will happen, then run it and explain the result.
- Change the outer loop to repeat 4 and the outer turn to 90 degrees. (Fewer squares; still a full circle, because 4 × 90 = 360.)
- Change the inner loop to repeat 3 and the inner turn to 120 degrees. (Triangles instead of squares.)
- Change the outer loop to repeat 12. What outer turn closes the circle? (30 degrees, because 12 × 30 = 360.)
- Debug challenge: give students a version with the outer turn placed inside the inner loop. What goes wrong, and why?
No computers? Micro:bit version
In MakeCode for the Micro:bit, use a repeat loop that shows a pattern on the LED screen, nested inside a loop that repeats the whole pattern with a pause. Students then change the counts and predict how long the light show will run.
Want a trained instructor to teach this for you?
Cyber Square sends a trained, police-checked instructor into your school every week. We bring the Micro:bit robotics kits and ready-made lessons that connect to the Grade 4 coding expectations, and your teacher can observe or learn alongside the class. Groups of up to 15 students, during the school day or as an after-school club.
See the full Programs page, or read about our program for Durham Region schools.
Other grades
See every grade's coding expectations, Grades 1 to 8, on one printable page: Ontario coding curriculum checklist.
Grade 4 coding: common questions
What is new in Grade 4 coding in Ontario?
Nested events. Grades 1 to 3 cover sequential, concurrent and repeating events. Grade 4 adds code where one loop or event sits inside another, for example repeating a square several times to make a pattern.
What tools can Grade 4 students use for coding?
Block-based tools work well: Scratch (with the Pen extension for drawing), MakeCode for the Micro:bit, or unplugged activities on paper. Any tool where students write, run, read and change code meets the expectation.
How long does a Grade 4 coding lesson take?
The nested-loop activity on this page fits in one 45 to 60 minute period: about 10 minutes unplugged, 25 to 35 minutes in Scratch, and 10 minutes to share and explain.
Is Grade 4 coding assessed?
Yes. C3.1 and C3.2 are specific expectations in the Grade 4 mathematics curriculum, so they are part of the Algebra strand that teachers assess and report on.
Can someone teach the coding part for us?
Yes. Cyber Square sends a trained, police-checked instructor into your school every week, with Micro:bit robotics kits and ready-made lessons connected to these expectations. Your teacher can observe or join in.
Get a proposal for your school
Tell us a little about your school. We'll email you a proposal with dates and pricing.
What happens next
- 1We reply by email within 1 business day.
- 2You pick a day and time that suits your timetable.
- 3Our instructor arrives with the kits.
Prefer email or phone? ijas@cybersquare.ca · +1 647-931-3171
