← ACARA Digital Technologies Years 9–10

Common function mistakes: print instead of return

Sends a value back to the caller. If a function only prints and has no return, it gives back None, so the caller cannot use the result.

Understanding Common function mistakes: print instead of return in ACARA Digital Technologies Years 9–10

What it does: Because return is indented inside the for loop, the function exits after the first number instead of adding them all. result is local to make_total(), so return is the way to send its value out to the code that called the function. print() only shows the value on screen. return sends it back, so x = double(4) stores 8. With print, x would be None. Arguments match parameters by position. Swapping them gives name = 15 and age = "Mia", which causes an error or a wrong result. The caller needs a real number to add 10 to. Using return w * h gives it one.

Common mistakes: The parameters are in the wrong order. The call take_away(10, 4) puts 10 into small and 4 into big, so the function returns -6 instead of 6. The header should be def take_away(big, small):. The function prints the answer instead of returning it, so x is None and x + 1 causes a TypeError. The line should be return n * 2.

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 629–680) and word search (Modules 629–707).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which function gives back a value the caller can store and use?
def double(n): return n * 2def double(n): print(n * 2)
Matches
def area(w, h): print(w * h) big = area(4, 5) + 10
↓
area() prints instead of returning, so it gives back None and None + 10 causes a TypeError. Replace print with return.
Applying
Meanings
Term
return
Meaning
Sends a value back to the caller. If a function only prints and has no return, it gives back None, so the caller cannot use the result.
Practice
def show_total(a, b):
Testing
Gaps
a + b
Check Answer
Spots
1def take_away(small, big):
2 return big - small

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

The 'Spider' badge — Web Weaver, 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 gives back a value the caller can store and use?
A. def double(n): return n * 2 ✓
B. def double(n): print(n * 2)
print() only shows the value on screen. return sends it back, so x = double(4) stores 8. With print, x would be None.
2. What does x hold after this code runs? def add(a, b): print(a + b) x = add(2, 3)
A. None ✓
B. 5
add() prints 5 but has no return statement, so it gives back None. That means x is None, not 5.
3. Why does total = add(2, 3) + 1 crash when add() only prints its answer?
A. add() returns None, and None + 1 is a TypeError ✓
B. add() returns 5, but Python cannot add 1 to it
A function with no return gives back None. You cannot add a number to None. Change print(a + b) to return a + b.
4. Which function finds the first even number in a list correctly?
A. for n in nums: if n % 2 == 0: print(n)
B. for n in nums: if n % 2 == 0: return n ✓
The caller needs the value, so the function must return it. Printing it shows the number but gives back None.
5. This function should return the sum of a list. What is the bug? def total(nums): s = 0 for n in nums: s += n return s
A. return should be replaced with print so the loop keeps going
B. return is inside the loop, so it stops after the first item ✓
Return ends the function straight away. Move return s outside the loop, lined up with the for, so every item is added first.

Match the Pairs

def add(a, b): print(a + b) total = add(2, 3) → total becomes None, because add() prints the sum but never returns it
def add(a, b): return a + b total = add(2, 3) → total becomes 5, because return sends the sum back to the caller
A return placed inside the loop ends the function on the first pass, so only the first item is handled → def total(nums): s = 0 for n in nums: s += n return s
A local variable only exists inside its function, so the caller must receive its value with return → def make_total(a, b): result = a + b return result
def area(w, h): print(w * h) big = area(4, 5) + 10 → area() prints instead of returning, so it gives back None and None + 10 causes a TypeError. Replace print with return.
def make_total(a, b): result = a + b make_total(2, 3) print(result) → result is a local variable, so it cannot be used outside the function and causes a NameError. Return it and store the answer from the call.

Key Term

return
Sends a value back to the caller. If a function only prints and has no return, it gives back None, so the caller cannot use the result.

Fill in the Blanks

1. def add(a, b): return a + b
Hint: Type the keyword that sends the sum back to the caller instead of just showing it.
2. def show(n): print(n) print(show(3) == None)
Hint: Type the value a function gives back when it prints but has no return statement.
3. def first(nums): for n in nums: return n
Hint: Type the keyword that immediately exits the function and hands a value to the caller, even inside a loop.
4. def divide(a, b): return a / b print(divide(10, 2))
Hint: Type the number that must go first, as the top number being divided, so the result is 5.0.
5. def area(w, h): return w * h print(area(3, 4))
Hint: Type the function name to call, because a local variable inside the function cannot be used outside it.

Spot the Error

Question 1
A def take_away(small, big):
B return big - small
C result = take_away(10, 4)
D print(result)
Line A — The parameters are in the wrong order. The call take_away(10, 4) puts 10 into small and 4 into big, so the function returns -6 instead of 6. The header should be def take_away(big, small):.
Question 2
A def double(n):
B print(n * 2)
C x = double(5)
D print(x + 1)
Line B — The function prints the answer instead of returning it, so x is None and x + 1 causes a TypeError. The line should be return n * 2.
Question 3
A def average(nums):
B total = sum(nums)
C avg = total / len(nums)
D print(avg)
E score = average([4, 6, 8])
F print(score + 1)
Line D — print only shows the value on screen. The function then gives back None, so score + 1 fails. It should be return avg.
Question 4
A def cube(n):
B result = n * n * n
C result
D volume = cube(3)
E print(volume + 1)
Line C — The return keyword is missing. The function works out the value but never sends it back, so volume is None and volume + 1 fails. The line should be return result.
Question 5
A def add_bonus(mark):
B new_mark = mark + 5
C new = add_bonus(60)
D print(new)
Line B — The result is stored in a local variable new_mark, which disappears when the function ends. With no return, the caller gets None. The line should be return mark + 5.

Student with a class code? Join your class →