← VCE Software Development U4O1

Functions calling other functions

A function that calls other small functions, each doing one job, so the program is built in parts. Each box in a hierarchy chart can become one function.

Understanding Functions calling other functions in VCE Software Development U4O1

What it does: A box in a hierarchy chart named Draw board turns into one function named draw_board that does just that job. main() holds the calls to the smaller functions, and calling main() at the bottom starts the program. Each function should do one job. get_total() only adds up prices, so it is easy to test and reuse. If a name needs 'and' to describe it, the function is probably doing more than one job. Split it into smaller functions. Code can call a function and use its returned value, so each function handles a single small task. To call a function you need brackets after its name, like greet() and show_score().

Common mistakes: The closing bracket of input() is missing. The line should be return input('Name: ') so the function gives back what the user typed. double() works out n * 2 but never returns it, so it gives back None. The line should be return n * 2 so show() can use the result.

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 3–79) 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
A function can call another function from inside its own body.
FalseTrue
Matches
def main(): greet show_score
↓
The function names are missing brackets (), so greet and show_score are never called
Applying
Meanings
Term
def main():
Meaning
A function that calls other small functions, each doing one job, so the program is built in parts. Each box in a hierarchy chart can become one function.
Practice
def get_score():
Testing
Gaps
main():
Check Answer
Spots
1def get_name():
2 return input('Name: '

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. A function can call another function from inside its own body.
A. True ✓
B. False
Yes. Calling one function from inside another is how a program is built from small parts, like main() calling other functions.
2. Which function follows the 'one job per function' idea?
A. def do_everything(): ask, add up, print, save and quit
B. def get_total(prices): return sum(prices) ✓
Each function should do one job. get_total() only adds up prices, so it is easy to test and reuse.
3. In a program built from small functions, what is the job of main()?
A. To call the other functions in the right order ✓
B. To do all of the work itself so other functions are not needed
main() acts like the top box of a hierarchy chart. It calls the other functions, and each of those does one small job.
4. Which is the correct way to have main() run a function called show_menu()?
A. def main(): show_menu
B. def main(): show_menu() ✓
Brackets are needed to call a function. Without (), show_menu just names the function and does not run it.
5. A hierarchy chart has a top box 'Play game' with two boxes below it: 'Get guess' and 'Check guess'. How could you turn these boxes into code?
A. Make one function for each box. The top function calls the two below it. ✓
B. Put all three boxes into one big function with no other functions.
Each box in a hierarchy chart can become one function. The top box calls the boxes under it.

Match the Pairs

def main(): greet() show_score() → main() calls two smaller functions, greet() and show_score(), so each does one job
total = add_tax(price) → A function call that uses the result of another function (add_tax) to do one part of the job
Each box in a hierarchy chart can become its own function → def draw_board(): print('Board')
A main() function calls the other functions to run the whole program → def main(): get_name() play_game() main()
def main(): greet show_score → The function names are missing brackets (), so greet and show_score are never called
def play(): ask_name() print(score()) def ask_name(): name = input() print(name) add_points(name) → One function is doing several jobs (asking, printing and scoring), so it is not one job per function

Key Term

def main():
A function that calls other small functions, each doing one job, so the program is built in parts. Each box in a hierarchy chart can become one function.

Fill in the Blanks

1. def main(): greet() show_score()
Hint: Type the keyword that defines a function.
2. def main(): print("Start") main()
Hint: Type the name of the function that runs the whole program. It is called on the last line.
3. def square(n): return n * n def area(s): return square(s) print(area(4))
Hint: Type the name of the helper function that area calls to do one job.
4. def main(): score = get_score() show_score(score)
Hint: Type the variable name that stores the value returned by the first function, so it can be passed to the next one.
5. # Chart box: Calculate total def calculate_total(): return 5 + 10
Hint: Turn the chart box label into a function name, using lowercase words joined by an underscore.

Spot the Error

Question 1
A def get_name():
B return input('Name: '
C def main():
D name = get_name()
E print('Hi', name)
Line B — The closing bracket of input() is missing. The line should be return input('Name: ') so the function gives back what the user typed.
Question 2
A def double(n):
B n * 2
C def show(n):
D print(double(n))
E show(4)
Line B — double() works out n * 2 but never returns it, so it gives back None. The line should be return n * 2 so show() can use the result.
Question 3
A def sq(n):
B return n * n
C def sum_sq(a, b)
D return sq(a) + sq(b)
Line C — A function definition must end with a colon. It should be def sum_sq(a, b): so the body can call sq() twice.
Question 4
A def main():
B print('Start')
C greet
D def greet():
E print('Hello!')
F main()
Line C — Without brackets, greet is just the name of the function and it is not called. It should be greet() so main() runs the greet function.
Question 5
A def get_score():
B return 80
C def show():
D print(getscore())
E show()
Line D — The function is called get_score, not getscore. Function names must match exactly when one function calls another.

Student with a class code? Join your class →