Purposes of naming conventions

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Purposes of naming conventions

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which statement best describes a naming convention?
A An agreed pattern for naming solution elements such as variables, functions and controls
B A rule that decides how fast a program runs
2. Which name is more meaningful for a variable that stores a student's final mark?
A finalMark
B x1
3. Why do development teams agree on one naming convention?
A So the computer can tell who wrote each line of code
B So every member's code looks consistent and is easy for others to read
4. A developer returns to their program six months later. How does a naming convention help?
A Clear, consistent names make the code easier to maintain and debug
B The program fixes its own errors when names follow a pattern
5. True or false: Following a naming convention changes what the program outputs.
A True - the output changes to match the names
B False - it only changes how readable the code is

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1total_marks = 0 AThe names x, y and z are meaningless, so readers cannot tell what they represent. Use names like price, discount_rate and discount_amount.
2txtStudentName / txtStudentEmail Bif student_age < minimum_age:
3Meaningful names make maintenance and debugging easier because a developer can quickly see what each element does CThe names mix camelCase, snake_case and PascalCase, so they are inconsistent. Pick one pattern, such as student_name, student_age and student_year.
4A naming convention improves readability because a name describes the data it holds DConsistent names that follow one shared pattern, so everyone on a team can understand each other's code
5x = 25 y = 0.1 z = x * y EA meaningful name that tells the reader what the variable stores, which makes the code readable
6studentName = 'Ava' student_age = 16 StudentYear = 11 Faverage_score = total_score / num_tests

Definitions

naming convention

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
studentName = "Ava" print(___________)
2.
price = 4.5 quantity = 3 totalPrice = price * ________
3.
def calcArea(width, height): return width * height area = ________(4, 5)
4.
scores = [80, 90] for _____ in scores: print(score)
5.
TAX = 0.1 price = 50 total = price + price * ___

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A player_name = input()
B playerAge = int(input())
C print(player_name, player_age)
Question 2
A price = 20.0
B quantity = 3
C item_name = 'Pen'
D tc = price * quantity
E print(item_name, total_cost)
Question 3
A scores = [70, 85, 90]
B total = 0
C for score in scores:
D total = total + Score
Question 4
A MAX_SPEED = 100
B current_speed = 80
C if current_speed > max_speed:
D print('Too fast')
Question 5
A age = 17
B flag = age >= 18
C if is_adult:
D print('Adult')

Answer Key

Purposes of naming conventions
Section A: Quick Questions
Q1
A — An agreed pattern for naming solution elements such as variables, functions and controls
Q2
A — finalMark
Q3
B — So every member's code looks consistent and is easy for others to read
Q4
A — Clear, consistent names make the code easier to maintain and debug
Q5
B — False - it only changes how readable the code is
Section B: Match the Pairs
Q1
total_marks = 0 → A meaningful name that tells the reader what the variable stores, which makes the code readable
Q2
txtStudentName / txtStudentEmail → Consistent names that follow one shared pattern, so everyone on a team can understand each other's code
Q3
Meaningful names make maintenance and debugging easier because a developer can quickly see what each element does → if student_age < minimum_age:
Q4
A naming convention improves readability because a name describes the data it holds → average_score = total_score / num_tests
Q5
x = 25 y = 0.1 z = x * y → The names x, y and z are meaningless, so readers cannot tell what they represent. Use names like price, discount_rate and discount_amount.
Q6
studentName = 'Ava' student_age = 16 StudentYear = 11 → The names mix camelCase, snake_case and PascalCase, so they are inconsistent. Pick one pattern, such as student_name, student_age and student_year.
Section C: Definitions
Q1
naming convention — An agreed pattern for naming variables, functions and controls so code is readable, consistent across a team and easier to maintain and debug.
Section D: Fill in the Blanks
Q1
studentName = "Ava" print(studentName)
Q2
price = 4.5 quantity = 3 totalPrice = price * quantity
Q3
def calcArea(width, height): return width * height area = calcArea(4, 5)
Q4
scores = [80, 90] for score in scores: print(score)
Q5
TAX = 0.1 price = 50 total = price + price * TAX
Section E: Spot the Error
Q1
B — The rest of the program uses snake_case, but this line switches to camelCase. Mixed styles make code harder to read and cause errors because later lines use player_age. It should be player_age = int(input()).
Q2
D — tc is a vague abbreviation that does not tell the reader what the value is. A meaningful name such as total_cost makes the code readable and easier to maintain. It should be total_cost = price * quantity.
Q3
D — Names are case sensitive, and the loop variable was named score in lowercase. Using Score breaks the consistent naming pattern and causes an error. It should be total = total + score.
Q4
C — The constant was named in UPPER_CASE, so it must be referred to by that same name. Writing max_speed breaks the convention and refers to a name that does not exist. It should be if current_speed > MAX_SPEED:.
Q5
B — flag is not a meaningful name, so the reader cannot tell what the Boolean stores. A descriptive name such as is_adult makes the condition on the next line read clearly. It should be is_adult = age >= 18.