DoAssignment study guide
B3.1 · Use clear names and indentation
Learn to use clear names and indentation through clear examples and targeted practice.
Ontario Grade 10 Computer Science
Introduction to Programming
Writing beginner programs that are easier to read
What you will learn
- Choose names that make a program’s values and actions easier to understand.
- Use consistent indentation to show which lines belong together.
- Read a short Python 3 example and trace its input, process, and output.
1. Names make meaning visible
- Prefer meaningful names over single letters or vague labels.
- Use one consistent naming style.
- A name should describe the information it represents.
2. Indentation shows grouping
- In Python, indent the lines that belong inside a grouped section.
- Keep lines at the same level aligned consistently.
- Return to the earlier indentation level when the group ends.
3. Read and check the code
- Check names and indentation separately.
- Trace the stated input to the expected output by reading the code.
- Improve readability without changing what the program is meant to do.
Worked example
Naming a borrowed-book count
Python 3
borrowed_book_count = input("How many books did you borrow? ")
print(borrowed_book_count)- Choose a nameThe value represents a count of borrowed books, so borrowed_book_count tells the reader more than x.
- Trace the exampleFor the hypothetical input 3, the program stores that entry under borrowed_book_count and displays the same value. This is a hand trace of the shown code, not a report of executed code.
Worked example
Improving a vague name
Python 3
reading_minutes = input("How many minutes did you read? ")
print(reading_minutes)- Identify the meaningThe value is the number of minutes spent reading. A name such as reading_minutes communicates that meaning directly.
- Trace the inputFor the hypothetical entry 20, the program stores the entry as reading_minutes and displays it. The name helps a reader understand what the displayed value refers to.
Worked example
Aligning an indented group
Python 3
wants_reminder = input("Would you like a reminder? ")
if wants_reminder == "yes":
print("Reminder: return your book.")- Notice the groupThe line that displays the reminder is indented under the if statement. That indentation shows it belongs to the statement above it. The name wants_reminder also describes the meaning of the input.
- Check the stated inputFor the hypothetical input yes, the condition matches, so the indented print line is the line associated with that case. For no, that line is not part of the matching case. This example is included to show grouping, not to extend the lesson beyond names and indentation.
Common mistakes and how to avoid them
Lesson summary
- Clear names help readers understand what information represents.
- Consistent indentation shows which lines are grouped together.
- A hand trace connects a stated input to the expected output without claiming the code was run.
- When classroom languages differ, follow the naming and indentation conventions taught for that language.
Check your understanding
Question 1
- x
- reading_page_count
- stuff
- answer
Show answer and explanation
Question 2
- The line belongs to the grouped section under the if statement.
- The line is a comment.
- The line changes the spelling of the variable name.
- The line is an input from the keyboard.
Show answer and explanation
Question 3
- borrowed_book_count
- How many books did you borrow?
- 3
- 20
Show answer and explanation
Key terms
- Clear name
- A name that gives a reader a useful clue about the information or action it represents.
- Indentation
- Spaces at the beginning of a line that show how the line is grouped with other code.
- Input
- Information provided to a program, such as an entry typed by a user.
- Process
- What a program does with information, such as storing an entry under a name.
- Output
- Information a program displays or otherwise provides.
Continue through ICS2O
View the complete ICS2O Ontario Grade 10 Computer Science curriculum and lessons
Tutor support for B3.1 · Use clear names and indentation
Working on B3.1 · Use clear names and indentation in ICS2O? 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.
برای مبحث B3.1 · کاربرد نام روشن و تورفتگی درست در درس ICS2O، سؤال و تلاش خود را همراه بیاورید. در جلسه میتوانید یک مثال کوچک را دنبال کنید و نخستین گامی را که خروجی با انتظار شما فرق دارد پیدا کنید. راهنمای معلم برنامهنویسی را ببینید یا جلسهٔ معارفهٔ رایگان ۳۰ دقیقهای درخواست کنید. زمان جلسه پس از پذیرش معلم قطعی میشود.
About this lesson and its review
Published by DoAssignment. This reviewed lesson follows Ontario Grade 10 Computer Science (ICS2O), expectation B3.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.