DoAssignment study guide

A4.1 · Use support documentation to resolve syntax issues

Learn to use support documentation to resolve syntax issues through clear examples and targeted practice.

Ontario Grade 12 Computer Science

Programming Concepts and Skills

ICS4U A4.1 | Read the language’s rules, check your code, and make a focused correction

In ICS3U, you learned to write and read program statements. In ICS4U, expectation A4.1 asks you to use support documentation to resolve syntax issues. Syntax is the set of rules for how code must be written in a particular programming language. A missing colon, misplaced bracket, or incorrectly written keyword can prevent a program from being understood as intended. The goal here is not to guess at a fix: identify the part of the code in question, consult documentation for the relevant rule, and make a correction that follows that rule. Documentation may be a language reference, a help page, or course-provided material. The examples use Python 3; another classroom language may have different rules.

What you will learn

  • Recognize a syntax issue as code that does not follow the programming language’s writing rules.
  • Use relevant support documentation to check the rule behind a reported syntax issue.
  • Make a small correction and explain why it follows the documented rule.
  • Describe a code example’s preconditions, input, expected result, and reasoning without claiming that unrun code was tested.

1. Start with the reported location and the language

A syntax message often points to a line and may describe what the language expected, such as a closing bracket or a colon. Treat that location as a useful clue, not as proof that the visible character on that line is the only problem. For example, an opening bracket on an earlier line may be missing its matching closing bracket.
First identify the language and version used by the program. Then read the reported line and the nearby code carefully. A rule from one language cannot automatically be applied to another: Python uses indentation to show the statements inside a block, while the exact block-writing rules vary by language.
This lesson is limited to syntax issues. A program can be written with valid syntax and still produce an unwanted result; that is a different kind of problem. Here, focus on code that does not follow the language’s writing rules.
  • Use the message and nearby code to locate the question.
  • Check documentation for the language and version you are using.
  • Do not assume a syntax correction also proves the program’s overall behaviour is correct.

2. Find and apply the relevant documentation rule

Look for documentation about the exact feature involved. If a line begins with `if`, search for the language’s rules for conditional statements. If the issue involves a function call, look for the rules or examples for function calls. A relevant example can show punctuation and layout that are easy to overlook in a brief message.
Compare the documented form with your code. Note the smallest difference that accounts for the syntax issue. Then correct that feature rather than rewriting unrelated lines. A focused change makes it easier to explain which rule you applied and to inspect the result.
After making the change, read the corrected statement against the documentation again. If you still cannot account for the message, revisit the nearby code and check whether an earlier unmatched symbol or unfinished statement affects the reported location. Use the course’s permitted tools and procedures for checking code; do not treat an unrun reading or trace as a test.
  • Search for a rule or example that matches the code feature.
  • Compare the code to the documented form before editing.
  • Make a small correction and check it against the same rule.

3. Use documentation examples as patterns, not guesses

Documentation examples are useful because they show how a language writes a construct. They are not necessarily complete solutions to your task. Identify the part that demonstrates the relevant syntax, then adapt that form to your own names and values.
When reviewing a proposed change, ask: What rule did I look up? Which part of the code did that rule help me correct? What input is the code intended to use, and what output do I expect from reading it? These questions keep the explanation precise without claiming that the program was run.
The examples below use short Python 3 snippets. For each one, the stated expected result follows from reading the corrected code. The examples do not claim execution.
  • Use the example to understand the writing pattern.
  • Keep the correction connected to a documented rule.
  • Describe an expected result as a reasoned expectation, not as a test result.

4. A repeatable classroom routine

When a syntax issue appears, record the language, the message, and the line it identifies. Read the surrounding code, then consult documentation for the construct on that line or nearby. Compare the required form with the code, make one targeted correction, and explain the rule that supports it.
If a correction does not address the issue, do not add unrelated changes at random. Check the nearby statements for a missing or extra punctuation mark, an unfinished expression, or an indentation pattern that conflicts with the documented example. Re-read the relevant documentation and revise only when you can state the reason.
This routine is deliberately simple: it turns a vague feeling that code “looks wrong” into a specific question about a language rule. Your explanation can be brief: name the construct, state the rule you consulted, and point to the correction.
  • Identify, look up, compare, correct, and review.
  • Explain why a correction matches the documented rule.
  • Keep the work focused on syntax.

Worked example

A missing colon in a conditional

A Python 3 learner intends to print `Ready` when `score` is at least 60. The line `if score >= 60` is followed by an indented print statement. Identify a syntax correction using documentation.

Python 3

score = 72
if score >= 60:
    print("Ready")
  1. Identify the construct
    The line begins with `if`, so consult Python 3 documentation or course support material for conditional statement syntax.
  2. Compare and correct
    The documented Python form places a colon after the condition. Add that punctuation mark and leave the indented statement in the block.
  3. State the expected result
    Precondition: `score` has a value that can be compared with 60. Input: the value of `score`. Reading the corrected code, if the value is 72, the condition is true and the expected output is `Ready`. This is a reasoned trace, not a claim that the code was run.
Answer: Add a colon after the condition: `if score >= 60:`.
Check: The correction follows the Python conditional-statement writing pattern: the condition line ends with a colon before the indented block.

Worked example

A string that needs a closing quotation mark

A Python 3 learner wants to display the word `Welcome` but writes `print("Welcome)`. Use support documentation to resolve the syntax issue.

Python 3

print("Welcome")
  1. Find the relevant rule
    The code starts a string with a double quotation mark. Look up Python’s documentation or course material for string literals and check how a quoted string is written.
  2. Match the opening and closing marks
    The string needs a closing double quotation mark before the closing parenthesis. Add the missing mark; do not change the intended word.
  3. Trace the expected output
    Precondition: the line is read as Python 3 code. Input: none. The corrected call asks Python to display the string, so the expected output is `Welcome`. This expectation comes from reading the code, not from an execution claim.
Answer: Write the call as `print("Welcome")`, with a closing quotation mark before the closing parenthesis.
Check: The correction makes the opening and closing quotation marks enclose the string, consistent with the documented form of a quoted string.

Worked example

A function call with a missing closing parenthesis

A learner intends to display the result of adding 8 and 5, but writes `print(8 + 5`. Use documentation to decide what syntax needs attention.

Python 3

print(8 + 5)
  1. Locate the unfinished call
    The opening parenthesis after `print` begins a function call. Consult documentation or course support material for the written form of a function call and compare the opening and closing punctuation.
  2. Complete the punctuation
    The call needs a closing parenthesis after the expression. Add it at the end of the line. The correction addresses the visible unfinished call; it does not change the addition.
  3. Describe the expected result
    Precondition: the line is read as Python 3 code. Input: the two integer values 8 and 5 in the expression. Reading the corrected expression, their sum is 13, so the expected displayed output is `13`. This is a trace by inspection, not a report of execution.
Answer: Write `print(8 + 5)` by adding the missing closing parenthesis.
Check: The function call’s parentheses now enclose the expression, matching the call pattern shown in Python support documentation.

Common mistakes and how to avoid them

Changing several lines before checking the documentation.
Correction: Look up the relevant syntax rule first and make a focused correction that you can explain.
Assuming the line named in a message must contain the original mistake.
Correction: Read nearby code as well; an unfinished expression or unmatched punctuation earlier can affect where an issue is reported.
Treating a reasoned expected output as proof that code was tested.
Correction: Say that the output is expected from reading or tracing the code unless it was actually checked using an allowed tool.
Applying a syntax rule from a different language or version.
Correction: Confirm the language and version, then consult support documentation that matches them.

Lesson summary

  • A syntax issue means code does not follow the writing rules of its language.
  • Use the message and nearby code to identify the relevant construct, then consult matching support documentation.
  • Compare the code with the documented rule, make a focused correction, and explain why it fits.
  • When describing an example, state its precondition, input, and expected output without claiming unperformed testing.

Check your understanding

Question 1

A Python 3 line reads `if total > 10` and is followed by an indented statement. What is the best next step?
  1. Add a colon because it looks right, without checking a rule.
  2. Consult support documentation for Python conditional syntax, compare the line, and add the required colon.
  3. Rewrite the indented statement even though its syntax has not been identified as the issue.
  4. Assume the code is valid because the condition is understandable.
Show answer and explanation
Consult support documentation for Python conditional syntax, compare the line, and add the required colon.
The documentation-based comparison identifies the relevant conditional rule and supports a focused correction.

Question 2

A Python string begins with a single quotation mark and has no matching closing quotation mark. Which documentation topic is most relevant?
  1. String literals
  2. Conditional statements
  3. Function parameters
  4. Numeric comparison
Show answer and explanation
String literals
The issue concerns how a string is delimited, so documentation about string literals is the relevant place to look.

Question 3

You read corrected code and calculate its expected output, but did not run it. Which statement is accurate?
  1. The program passed a test.
  2. The output is guaranteed for every possible input.
  3. The output is expected from reading the code; it has not been reported as tested.
  4. Documentation is unnecessary once an output is predicted.
Show answer and explanation
The output is expected from reading the code; it has not been reported as tested.
A trace by inspection supports an expected result, but does not establish that code was executed or tested.

Key terms

Syntax
The writing rules that determine how code must be arranged and punctuated in a programming language.
Support documentation
Language references, help pages, or course materials that explain rules and show examples.
Syntax issue
Code that does not follow the writing rules required by its programming language.
Trace
A step-by-step reading of code to work out what it is expected to do for stated input.

Continue through ICS4U

View the complete ICS4U Ontario Grade 12 Computer Science curriculum and lessons

Tutor support for A4.1 · Use support documentation to resolve syntax issues

Working on A4.1 · Use support documentation to resolve syntax issues in ICS4U? Bring the question and your own attempt. In a live session, you can trace a small example and find the first step where the output differs from what you expected. Ask about the first step that does not make sense, then try a similar question yourself.

Explore coding 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.

برای مبحث A4.1 · کاربرد مستندات برای رفع خطای نوشتاری در درس ICS4U، سؤال و تلاش خود را همراه بیاورید. در جلسه می‌توانید یک مثال کوچک را دنبال کنید و نخستین گامی را که خروجی با انتظار شما فرق دارد پیدا کنید. راهنمای معلم برنامه‌نویسی را ببینید یا جلسهٔ معارفهٔ رایگان ۳۰ دقیقه‌ای درخواست کنید. زمان جلسه پس از پذیرش معلم قطعی می‌شود.

About this lesson and its review

Published by DoAssignment. This reviewed lesson follows Ontario Grade 12 Computer Science (ICS4U), expectation A4.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.

Official curriculum reference

Report a correction or ask a question