← VCE Software Development U3O1

Stubs: placeholder code and comments for future development

A Python statement that does nothing. It fills a stub's empty body, often beside a # TODO comment, so the program still runs while the real code is written later.

Understanding Stubs: placeholder code and comments for future development in VCE Software Development U3O1

What it does: The stub returns a fixed value, 100, so code that calls get_total() still works and can be tested. The TODO shows it needs replacing. A stub is a placeholder. It lets you test other parts of the program before the real code exists. It does not improve speed. pass is a statement that does nothing. It only fills the empty body so Python does not raise a syntax error. A function header must end with a colon. The stub is still just a def line, an indented pass and a comment.

Common mistakes: The stub show_menu() has no parameters, so passing 1 causes a TypeError. The call should be show_menu() with empty brackets. Python comments start with #, not //. The TODO comment should be '# TODO: write to file'.

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 48–71) and word search (Modules 10–71).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which function is a valid stub in Python?
def calculate_total():def calculate_total(): pass
Matches
def load_data(): # TODO: read the file
↓
The function has no body. A comment is not a statement, so Python raises an IndentationError. Add an indented pass line.
Applying
Meanings
Term
pass
Meaning
A Python statement that does nothing. It fills a stub's empty body, often beside a # TODO comment, so the program still runs while the real code is written later.
Practice
def calculate_tax(income):
Testing
Gaps
Check Answer
Spots
3 pass
4show_menu(1)

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

The 'Dolphin' badge — Reef Streak, 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 function is a valid stub in Python?
A. def calculate_total(): pass ✓
B. def calculate_total():
A function needs a body to run. pass fills the body so the program still works while the real code is written later.
2. What is the main purpose of a stub?
A. Make the finished function run faster
B. Mark work still to do so the rest of the program can run ✓
A stub is a placeholder. It lets you test other parts of the program before the real code exists. It does not improve speed.
3. Which comment is the usual way to flag a stub that needs to be finished?
A. # TODO: add the discount calculation ✓
B. # This function is complete
A # TODO comment reminds the programmer what work is still to do. Calling a stub complete would be misleading.
4. What does the pass statement do when a stub is called?
A. Stops the program with an error
B. Nothing, and the program carries on ✓
pass is a statement that does nothing. It only fills the empty body so Python does not raise a syntax error.
5. A stub for get_tax_rate() must give the rest of the program a number to test with. Which stub does this?
A. def get_tax_rate(): return 0.1 ✓
B. def get_tax_rate(): pass
A stub that returns a fixed test value gives other code something to work with. A stub with only pass returns None, which can cause errors in calculations.

Match the Pairs

def save_scores(): pass → A stub function: it has a name but an empty body, so the program runs while the real code is still to be written.
# TODO: add validation → A comment that marks work still to do, so developers can find it later and replace the stub with real code.
A stub can return a fixed test value so the rest of the program can be tested before the real calculation is written. → def get_total(): return 100 # TODO: real total
A stub for a class uses pass as its body, so objects can be created before its attributes and methods are written. → class Player: pass # TODO: add attributes
def load_data(): # TODO: read the file → The function has no body. A comment is not a statement, so Python raises an IndentationError. Add an indented pass line.
def show_menu(): pass print('Menu') → The stub is replaced by real code but pass was left in. It is now unnecessary and misleading, so delete pass when the real code goes in.

Key Term

pass
A Python statement that does nothing. It fills a stub's empty body, often beside a # TODO comment, so the program still runs while the real code is written later.

Fill in the Blanks

1. def total(): # TODO: add up prices pass
Hint: Type the statement that does nothing and keeps the empty stub body valid.
2. def save(): # TODO: write to file pass
Hint: Type the keyword that starts a function definition.
3. def getmark(): # TODO: read the mark pass
Hint: Type the conventional capitalised word in a comment that flags work still to be done.
4. def price(item): # TODO: look up price return 9.99
Hint: Type the keyword that sends a fixed test value back to the caller from this stub.
5. def double(n): # stub was: pass return n * 2
Hint: Type the arithmetic operator that replaces the stub with real code to double the number.

Spot the Error

Question 1
A def show_menu():
B # TODO: print the menu
C pass
D show_menu(1)
Line D — The stub show_menu() has no parameters, so passing 1 causes a TypeError. The call should be show_menu() with empty brackets.
Question 2
A def save_data():
B // TODO: write to file
C pass
D save_data()
Line B — Python comments start with #, not //. The TODO comment should be '# TODO: write to file'.
Question 3
A def load_scores()
B # TODO: read the file
C pass
D load_scores()
Line A — The function header is missing its colon. It should be 'def load_scores():' so the indented stub body belongs to it.
Question 4
A def get_age():
B # TODO: use input()
C return 16
D age == get_age()
E print(age)
Line D — == compares values and age does not exist yet, so this causes a NameError. Assignment needs a single =: age = get_age().
Question 5
A Class Player:
B # TODO: add attributes
C pass
D p = Player()
Line A — Python keywords are case-sensitive. The keyword must be lowercase: 'class Player:'.

Student with a class code? Join your class →