← VCE Software Development U3O1

Functions calling other functions

A function can call another function inside its body. Big problems get split into small helper functions that each do one job, like boxes in a decomposition.

Understanding Functions calling other functions in VCE Software Development U3O1

What it does: Each box in a decomposition matches one function with one job, here showing the score. main() calls get_name() and show_menu(), so each helper solves one sub-problem. Inside the body of main(), writing greet() with brackets calls the function greet. Without brackets it does not run. Good functions have one job each. Small helpers are easier to read, test and fix. Functions can call other functions. This is how big programs are built from small parts. Defining a function only saves it. It runs only when something calls it. add_bonus() does one job only. do_everything() mixes input, output and maths, so it is harder to reuse.

Common mistakes: A function definition must end with a colon. It should be def sum_squares(a, b):. To call a helper function you need brackets. Without them, name just stores the function itself. It should be name = get_name().

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 72–96) and word search (Modules 72–113).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which code shows a function calling another function?
def main(): greet()def main: greet
Matches
def main(): greet main()
↓
greet is missing its brackets, so the helper function is never called. It should be greet().
Applying
Meanings
Term
def main(): greet()
Meaning
A function can call another function inside its body. Big problems get split into small helper functions that each do one job, like boxes in a decomposition.
Practice
def show_title():
Testing
Gaps
def (): cheer()
Check Answer
Spots
2 return n * n
3def sum_squares(a, b)

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

The 'Cosmic Owl' badge — Comprehension Guru, 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 code shows a function calling another function?
A. def main: greet
B. def main(): greet() ✓
Inside the body of main(), writing greet() with brackets calls the function greet. Without brackets it does not run.
2. A program has a helper function called get_name(). Which is the best job for that function?
A. Only ask the user for their name ✓
B. Ask for a name, do the maths, draw the score and print the report
Good functions have one job each. Small helpers are easier to read, test and fix.
3. True or false: one function can call another function inside its body.
A. True ✓
B. False
Functions can call other functions. This is how big programs are built from small parts.
4. In a decomposition, a problem is split into boxes: 'Get score', 'Add bonus', 'Show result'. How do these boxes match Python code?
A. Each box becomes its own function ✓
B. All boxes go into one long function
Matching one decomposition box to one function keeps each job separate and clear.
5. Which main() runs the helper functions in a sensible order?
A. def main(): get_score show_result
B. def main(): get_score() show_result() ✓
Each helper needs brackets () to be called. Calls run in the order they are written.

Match the Pairs

def main(): greet() → The main function calls the greet function, so main uses greet as a helper to do one job
def area(w, h): return w * h → A small helper function that does just one job: work out an area and give it back
A decomposition box called 'Show the score' becomes its own function that main() can call → def show_score(score): print(score)
A big problem is split up so main() calls one small helper function for each sub-problem → def main(): get_name() show_menu()
def main(): greet main() → greet is missing its brackets, so the helper function is never called. It should be greet().
def main(): show_score() main() → show_score() is called but was never defined with def, so Python gives a NameError. Define the helper first.

Key Term

def main(): greet()
A function can call another function inside its body. Big problems get split into small helper functions that each do one job, like boxes in a decomposition.

Fill in the Blanks

1. def cheer(): print("Go!") def main(): cheer()
Hint: Type the usual name of the function that calls the helper functions to run the program.
2. def main(): greet() goodbye()
Hint: Type the keyword that starts a function definition.
3. def show(n): print(n * n) def main(): show(5)
Hint: Type the built-in function that displays a value on the screen.
4. def add(a, b): return a + b def main(): print(add(2, 3)) main()
Hint: Type the operator that adds the two values in the helper function.
5. def area(w, h): return w * h def main(): print(area(3, 4))
Hint: Type the name of the helper function that main() calls to do its job.

Spot the Error

Question 1
A def square(n):
B return n * n
C def sum_squares(a, b)
D return square(a) + square(b)
E print(sum_squares(2, 3))
Line C — A function definition must end with a colon. It should be def sum_squares(a, b):
Question 2
A def get_name():
B return "Sam"
C def welcome():
D name = get_name
E print("Hi " + name)
F welcome()
Line D — To call a helper function you need brackets. Without them, name just stores the function itself. It should be name = get_name().
Question 3
A define add_tax(price):
B return price * 1.1
C def total(price):
D return add_tax(price)
E print(total(10))
Line A — Python uses the keyword def, not define, to create a function. It should be def add_tax(price):
Question 4
A def show_line():
B print("-" * 10
C def show_title():
D show_line()
E print("Quiz")
Line B — The print( bracket is never closed. It should be print("-" * 10).
Question 5
A def say_hi:
B print("Hi!")
C def main():
D say_hi()
E main()
Line A — A function definition needs brackets after its name, even with no parameters. It should be def say_hi():

Student with a class code? Join your class →