← VCE Software Development U4O1

Readability improvements in code

Code that people can quickly understand, using clear names, consistent indentation and spacing, short functions with no repeated code, and helpful comments.

Understanding Readability improvements in code in VCE Software Development U4O1

What it does: The print line is written once in greet() and reused, so there is no copied code to read or fix. Each block is indented the same amount, and spacing around the operator makes the structure easy to see. A meaningful name like studentAge tells the reader what the value stores. Names like x1 force people to guess. Consistent indentation shows which lines belong together, so the structure is easy to see. Removing repeated code keeps the program shorter and easier to follow. A fix only needs to be made once. These four features help people quickly understand code. That is what makes it readable.

Common mistakes: The function is called total_price, but the call uses totalprice. Names must be used consistently, otherwise Python gives a NameError. It should be print(total_price(5, 3)). The parameters need a comma between them. It should be def area(width, height):.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 82–114) and word search (Modules 3–114).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which variable name makes code more readable?
studentAgex1
Matches
x = a * b z = x - 5
↓
Unclear single-letter names do not tell the reader what the values mean. Use names like subtotal and discount.
Applying
Meanings
Term
readable code
Meaning
Code that people can quickly understand, using clear names, consistent indentation and spacing, short functions with no repeated code, and helpful comments.
Practice
def average_mark(marks):
Testing
Gaps
total = price *
Check Answer
Spots
3 return total
4print(totalprice(5, 3))

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Cheetah' badge — Savannah Sprinter, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which variable name makes code more readable?
A. x1
B. studentAge ✓
A meaningful name like studentAge tells the reader what the value stores. Names like x1 force people to guess.
2. Which choice shows good indentation inside an if statement?
A. The lines inside the if are indented the same amount ✓
B. The lines inside the if are lined up randomly
Consistent indentation shows which lines belong together, so the structure is easy to see.
3. The same 5 lines of code are copied in four places in a program. How can you make it more readable?
A. Leave the copies so each place is self-contained
B. Move them into one function and call it four times ✓
Removing repeated code keeps the program shorter and easier to follow. A fix only needs to be made once.
4. True or false: Readable code uses clear names, consistent layout, short functions and helpful comments.
A. True ✓
B. False
These four features help people quickly understand code. That is what makes it readable.
5. Which function name is the most readable?
A. calculateTotalPrice() ✓
B. doStuff()
A function name should describe what it does. doStuff() says nothing about its job.

Match the Pairs

total_price = price * quantity → A meaningful variable name that tells the reader what the value stores
def show_total(price, qty): return price * qty → A short function with consistent indentation that does one clear job
Removing repeated code by putting it in a function that you call each time → def greet(name): print("Hello " + name) greet("Ava") greet("Liam")
Consistent indentation and spacing show which lines belong together → if score >= 50: print("Pass") else: print("Try again")
x = a * b z = x - 5 → Unclear single-letter names do not tell the reader what the values mean. Use names like subtotal and discount.
print("Hi Ava") print("Hi Liam") print("Hi Mia") print("Hi Noah") → The same line is repeated many times. Use a function or a loop so the code is written once.

Key Term

readable code
Code that people can quickly understand, using clear names, consistent indentation and spacing, short functions with no repeated code, and helpful comments.

Fill in the Blanks

1. total = price * quantity print("Total:", total)
Hint: Type the clear variable name that holds how many items were bought.
2. def border(): print("-" * 20)
Hint: Type the keyword that creates a function, so repeated code can be written once and reused.
3. # Add 10 percent GST to the price gst = price * 0.1
Hint: Type the symbol that starts a helpful comment line in Python.
4. for mark in marks: print(mark)
Hint: Type the keyword that repeats code for each item in a list instead of copying lines.
5. def addgst(price): return price * 1.1 print(addgst(50))
Hint: Type the keyword that sends a value back from a function so the same code can be reused.

Spot the Error

Question 1
A def total_price(price, qty):
B total = price * qty
C return total
D print(totalprice(5, 3))
Line D — The function is called total_price, but the call uses totalprice. Names must be used consistently, otherwise Python gives a NameError. It should be print(total_price(5, 3)).
Question 2
A def area(width height):
B return width * height
C room = area(4, 5)
D print(room)
Line A — The parameters need a comma between them. It should be def area(width, height):.
Question 3
A names = ["Ava", "Liam", "Mia"]
B for name in names
C print("Hi", name)
Line B — A for loop line must end with a colon. The loop replaces three repeated print lines, but it needs for name in names: to work.
Question 4
A def greet(name):
B return "Hi " + name
C for student in ["Ava", "Zoe"]:
D print(greet(studnet))
Line D — The loop variable is student, but this line spells it studnet. A clear name only helps if it is used consistently, otherwise Python gives a NameError. It should be print(greet(student)).
Question 5
A score = 85
B if score => 50:
C print("Pass")
D else:
E print("Fail")
Line B — The operator for greater than or equal to is >=, not =>. It should be if score >= 50:.

Student with a class code? Join your class →