Ontario Grade 7 Mathematics · Grade 7 Math C3.1
C3.1 · Write efficient code using counts, subprograms, and control structures
Code is a set of instructions that a computer or a coding device follows. You may already know how to put instructions in order. For example…
Ontario Grade 7 Mathematics
Algebra
Plan clear instructions by spotting repeated actions and organizing them well
What you will learn
- Describe what code instructions do in a simple sequence.
- Use a count to repeat an instruction a chosen number of times.
- Use a subprogram to give a reusable group of instructions a name.
- Choose among sequence, repetition, and choice to make code clearer and more efficient.
- Check that code gives the intended result.
1. Start with clear instructions
- A sequence runs instructions in order.
- A count tells how many times an action or group of actions repeats.
- Good code is both clear and suited to its task.
2. Use counts for repeated actions
- A repeat structure saves rewriting when actions happen again in the same way.
- Check that the count matches the number of repetitions needed.
- The actions inside the repeat are the actions that happen again.
3. Give reusable instructions a name
- A subprogram is a reusable, named group of instructions.
- Use a clear name that describes the group’s job.
- A repeat count can tell the program how many times to use a subprogram.
4. Choose the control structure that fits
- Sequence means instructions run in order.
- Repetition means instructions run again.
- Choice means the program follows a path based on a condition.
- Test the code by tracing its instructions and checking the result.
Three ways to organize instructions
| Code pattern | What it does | When it fits |
|---|---|---|
| Sequence | Runs instructions in order | Actions happen once in a set order |
| Repetition | Runs instructions again | An action or group is needed several times |
| Choice | Selects an action based on a condition | The program needs different responses |
| Subprogram | Names a reusable group of instructions | A group needs a clear name or is used again |
Worked example
Draw a square with a count
- Name the repeated actionsEach side uses the same two actions: move forward one side length, then turn a quarter-turn. A square has four sides, so this pair is needed four times.
- Use a countPut the repeated pair inside a repeat instruction. The count is four because the robot must draw four sides and make four turns to return to its starting direction.
Worked example
Use a subprogram in a larger plan
- Make a named groupPut the four actions for one mark in a subprogram. A name such as “draw one mark” tells the reader what the group does.
- Use the group three timesThe marks are identical, so the main code can repeat the named subprogram three times. The subprogram keeps the details together, and the count shows how many marks to draw.
Worked example
Select a choice based on a condition
- State the conditionThe condition is whether the learner’s answer matches the target answer. It can be true or false.
- Give an action for each resultIf the condition is true, show a success message. Otherwise, show a try-again message. This is choice because the program selects an action based on the condition.
Common mistakes and how to avoid them
Lesson summary
- A sequence runs instructions in order.
- A count tells how many times instructions repeat.
- A subprogram is a named group of instructions that can be used in a larger program.
- Control structures organize when instructions run: sequence, repetition, and choice.
- Trace the instructions and check that the result matches the task.
Check your understanding
Question 1
- A count of six
- A subprogram name only
- A choice with no condition
- A sequence with no repeated actions
Show answer and explanation
Question 2
- A subprogram
- A count
- A condition
- A sequence that must happen only once
Show answer and explanation
Question 3
- Choice
- A repeat count
- A subprogram name without instructions
- A sequence with no condition
Show answer and explanation
Key terms
- Code
- Instructions that tell a computer or coding device what to do.
- Sequence
- Instructions that run in a set order.
- Count
- A number that tells how many times an action or group of actions repeats.
- Control structure
- A code pattern that controls what instructions happen and when.
- Repetition
- A control structure that runs an instruction or group again.
- Subprogram
- A named group of instructions that can be used as part of a larger program.
- Condition
- A rule that can be true or false and can guide a choice in code.
- Efficient code
- Code that completes the task clearly without unnecessary repeated writing.
Continue through Grade 7 Math
View the complete Grade 7 Math Ontario Grade 7 Mathematics curriculum and lessons
- C2.4 · Solve, verify, and graph whole-number inequalities
- C3.2 · Modify code and explain changes to its output and efficiency
- C1.1 · Compare repeating, growing, and shrinking patterns by rate and starting value
- C1.2 · Represent number patterns with tables, expressions, and linear equations
- C1.3 · Extend patterns and use their rules to find missing values
- C2.1 · Add and subtract first-degree monomials using models
Tutor support for C3.1 · Write efficient code using counts, subprograms, and control structures
Working on C3.1 · Write efficient code using counts, subprograms, and control structures in Grade 7 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.1 · نوشتن کد کارآمد با شمارش، زیربرنامه و ساختارهای کنترلی در درس Grade 7 Math، سؤال و تلاش خود را همراه بیاورید. در جلسه میتوانید یک ورودی کوچک را گامبهگام دنبال کنید، خروجی مورد انتظار و واقعی را مقایسه کنید و یک حالت مرزی را بیازمایید. راهنمای معلم ریاضی را ببینید یا جلسهٔ معارفهٔ رایگان ۳۰ دقیقهای درخواست کنید. زمان جلسه پس از پذیرش معلم قطعی میشود.
About this lesson and its review
Published by DoAssignment. This reviewed lesson follows Ontario Grade 7 Mathematics, expectation C3.1. 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.