Ontario Grade 6 Mathematics · Grade 6 Math C3.2
C3.2 · Change code and explain effects on output and efficiency
Code is a set of instructions that a computer follows. Output is what the code produces, such as a number or a list of numbers. When you change…
Ontario Grade 6 Mathematics
Algebra
See how a small code change can change a result or the way a program is written
What you will learn
- Describe the output of a short set of code instructions.
- Change one part of code and explain how the output changes.
- Compare two pieces of code that make the same output and explain which is more efficient to write.
1. Trace instructions to find the output
- Output is the result produced by running code.
- Trace code in the order its instructions are given.
- A repeat instruction carries out its inner instruction the stated number of times.
2. Change code and explain what changes
- Compare the original code and changed code.
- Change one part at a time when you want to identify its effect.
- Explain why the output changed by referring to the instruction that changed.
3. Compare how efficiently code is written
- Efficiency here is about avoiding unnecessary repeated writing.
- A repeat instruction can make code shorter while keeping the same output.
- Always check that the code still gives the intended result.
4. A reliable way to review a code change
- Trace first, edit second, and compare outputs last.
- For efficiency, compare the written instructions and confirm that the results match.
- Use a clear sentence to link the code edit to its effect.
Worked example
Example 1: Change the number of repetitions
- Trace the original codeStart at 1. Add 4 three times, keeping the running value after each addition.
- Trace the changed codeThe changed code adds 4 one extra time. Continue from the original result and add 4 once more.
- Explain the effectThe repeat count increased from three to four. The program added one extra group of 4, so the output increased from 13 to 17.
Worked example
Example 2: Change the instruction inside the repeat
- Trace the original codeThe program adds 3 four times. Starting at 0, record each new value until all four additions are done.
- Trace the changed codeNow each repetition adds 5 instead. The program still repeats four times, so use four additions of 5.
- Compare the outputsThe repeat count stayed the same, but each addition became 2 larger. Across four repetitions, the changed program produces an output 8 larger.
Worked example
Example 3: Use repetition to avoid repeated writing
- Find Program A's outputProgram A adds 2 four times. Starting at 0, its running total ends at 8.
- Find Program B's outputProgram B also carries out “add 2” four times. It therefore gives the same output.
- Compare the written codeBoth programs do the same task and give the same output. Program B is more efficient to write because one repeat instruction replaces four separate copies of the same instruction.
Common mistakes and how to avoid them
Lesson summary
- Output is the result produced by running code.
- Trace instructions in order and count repeat instructions carefully.
- Change one part of code, trace it again, and explain how that edit affects the output.
- A repeat instruction can make code more efficient to write when it replaces repeated copies and keeps the same output.
Check your understanding
Question 1
- 8
- 9
- 11
- 12
Show answer and explanation
Question 2
- It stays 8 because only the repeat count changed.
- It increases by 4, from 8 to 12.
- It increases by 3, from 8 to 11.
- It becomes 3 because the new repeat count is 3.
Show answer and explanation
Question 3
- It avoids writing the same instruction separately, while still carrying it out five times.
- It makes the output five times smaller.
- It carries out the instruction only once.
- It removes the need to check the output.
Show answer and explanation
Key terms
- Code
- Instructions written so a computer can carry them out.
- Output
- The result produced when code runs.
- Trace
- A record of what happens as each instruction is followed.
- Repeat instruction
- An instruction that tells a computer to carry out another instruction a set number of times.
- Efficiency
- Doing a task without unnecessary work. Here, it includes avoiding repeated writing when the same output can be made with a repeat instruction.
Continue through Grade 6 Math
View the complete Grade 6 Math Ontario Grade 6 Mathematics curriculum and lessons
- C3.1 · Write efficient code with conditionals and control structures
- D1.1 · Distinguish discrete from continuous data
- C1.1 · Identify repeating, growing, shrinking, and linear patterns
- C1.2 · Represent patterns with tables, graphs, and expressions
- C1.3 · Use pattern rules to predict and find missing terms
- C1.4 · Create patterns showing whole-number and decimal relationships
Tutor support for C3.2 · Change code and explain effects on output and efficiency
Working on C3.2 · Change code and explain effects on output and efficiency in Grade 6 Math? Bring the question and your own attempt. In a live session, you can trace a small input step by step, compare expected and actual output, and test an edge case. Ask about the first step that does not make sense, then try a similar question yourself.
Explore math tutoring · Request an eligible free 30-minute introduction. Your request is matched by subject and language; a tutor must accept before a time is confirmed.
برای مبحث C3.2 · تغییر کد و توضیح اثر آن بر خروجی و کارایی در درس Grade 6 Math، سؤال و تلاش خود را همراه بیاورید. در جلسه میتوانید یک ورودی کوچک را گامبهگام دنبال کنید، خروجی مورد انتظار و واقعی را مقایسه کنید و یک حالت مرزی را بیازمایید. راهنمای معلم ریاضی را ببینید یا جلسهٔ معارفهٔ رایگان ۳۰ دقیقهای درخواست کنید. زمان جلسه پس از پذیرش معلم قطعی میشود.
About this lesson and its review
Published by DoAssignment. This reviewed lesson follows Ontario Grade 6 Mathematics, expectation C3.2. It is a study resource, not an official curriculum publication.
Before publication, content is checked for structure, mathematical or chemical notation, calculations, course boundaries, and readability. Errors can still occur, so corrections are welcomed.