Python snake_case naming

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

Python snake_case naming

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which variable name follows Python snake_case style?
A studentScore
B student_score
2. Which function name follows Python snake_case style?
A calculate_average()
B CalculateAverage()
3. True or false: snake_case names can contain capital letters in the middle of the name.
A False
B True
4. A programmer's Python program already uses total_cost and item_count. Which name should they choose for a new variable?
A discountRate
B discount_rate
5. Which character joins the words in a snake_case name?
A An underscore _
B A hyphen -

Match the Pairs

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

Left columnRight column
1student_score = 85 AA Python function named in snake_case so it follows the standard Python style
2def calculate_total_marks(): BThe styles are mixed. bonusPoints is camelCase and should be bonus_points to match total_marks.
3snake_case is different from camelCase because it uses underscores instead of capital letters to separate words Cfirst_name (not firstName)
4Follow one naming style consistently so every variable in a program is easy to read Dtotal_marks = 0 average_mark = 0
5studentScore = 85 EThis uses camelCase, but Python style expects snake_case. It should be student_score.
6total_marks = 90 bonusPoints = 5 FA Python variable named in snake_case: lowercase words joined by underscores

Definitions

snake_case

Fill in the Blanks

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

1.
_____________ = 85 print(student_score)
2.
def _________________(total, count): return total / count avg = calculate_average(240, 3)
3.
_________ = "Nguyen" full_name = "Ava " + last_name
4.
___ get_total_points(points): return sum(points)
5.
__________ = 0 if new_score > high_score: high_score = new_score

Spot the Error

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

Question 1
A pass_mark = 50
B studentScore = 85
C if student_score >= pass_mark:
D print("Pass")
Question 2
A def getAverage(marks):
B total = sum(marks)
C return total / len(marks)
Question 3
A first_name = "Ava"
B last_name = "Nguyen"
C full_name = first_name + " "
D fullName += last_name
E print(full_name)
Question 4
A num_sold = 12
B unit_cost = 4
C total = num_sold * unit-cost
D print(total)
Question 5
A def show_total(item_count):
B price = 3
C cost = itemCount * price
D return cost

Answer Key

Python snake_case naming
Section A: Quick Questions
Q1
B — student_score
Q2
A — calculate_average()
Q3
A — False
Q4
B — discount_rate
Q5
A — An underscore _
Section B: Match the Pairs
Q1
student_score = 85 → A Python variable named in snake_case: lowercase words joined by underscores
Q2
def calculate_total_marks(): → A Python function named in snake_case so it follows the standard Python style
Q3
snake_case is different from camelCase because it uses underscores instead of capital letters to separate words → first_name (not firstName)
Q4
Follow one naming style consistently so every variable in a program is easy to read → total_marks = 0 average_mark = 0
Q5
studentScore = 85 → This uses camelCase, but Python style expects snake_case. It should be student_score.
Q6
total_marks = 90 bonusPoints = 5 → The styles are mixed. bonusPoints is camelCase and should be bonus_points to match total_marks.
Section C: Definitions
Q1
snake_case — A naming style where all letters are lowercase and words are joined by underscores, like student_score. Python uses it for variables and functions, and it should be used consistently.
Section D: Fill in the Blanks
Q1
student_score = 85 print(student_score)
Q2
def calculate_average(total, count): return total / count avg = calculate_average(240, 3)
Q3
last_name = "Nguyen" full_name = "Ava " + last_name
Q4
def get_total_points(points): return sum(points)
Q5
high_score = 0 if new_score > high_score: high_score = new_score
Section E: Spot the Error
Q1
B — studentScore is camelCase. Python style uses snake_case for variables, so it should be student_score = 85. Line 3 also uses student_score, so the names would not match.
Q2
A — Python function names should use snake_case, not camelCase. The line should be def get_average(marks):
Q3
D — The variable was created as full_name, but this line uses camelCase fullName. Stay consistent with one style: full_name += last_name.
Q4
C — A hyphen is not allowed in a variable name. Python reads unit-cost as unit minus cost. Words must be joined with an underscore: unit_cost.
Q5
C — The parameter is named item_count in snake_case, but this line uses camelCase itemCount. It should be cost = item_count * price.