← ACARA Digital Technologies Years 7–8

print() inside a function versus return

Hands a value back to the caller so it can be stored in a variable or used in a calculation. print() inside a function only shows the value on screen, and the function then gives back None.

Understanding print() inside a function versus return in ACARA Digital Technologies Years 7–8

What it does: This only works well when add() uses return. The value 5 is stored in total and can be used later. A returned value of 5 can be multiplied by 2 to give 10. A function that only prints would give None and cause an error. add() gives back None, and Python cannot add None and a number. You need return a + b for this to work. return sends the value out of the function, so the caller can keep it in a variable or use it in maths.

Common mistakes: print() only shows the sum on screen and the function then gives back None. So total holds None, not 5. The line should be 'return a + b' so the value is handed back and can be stored. print() shows the temperature but the function returns None. Comparing None > 70 causes a TypeError. Use 'return c * 9 / 5 + 32' so the result can be used in the comparison.

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 522–560) and word search (Modules 522–580).

Take this worksheet further — free with Cloodit

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

Learning
Duo
A function has print(a + b) as its last line and no return. What does result = add(2, 3) store in result?
None5
Matches
def square(n): print(n * n) answer = square(4) + 1
↓
square() only prints and gives back None, so adding 1 to None causes a TypeError. Use return n * n instead of print(n * n).
Applying
Meanings
Term
return
Meaning
Hands a value back to the caller so it can be stored in a variable or used in a calculation. print() inside a function only shows the value on screen, and the function then gives back None.
Practice
def add_bonus(score):
Testing
Gaps
a + b
Check Answer
Spots
1def add(a, b):
2 print(a + b)

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

The 'Giant Isopod' badge — Patient Builder, 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 has print(a + b) as its last line and no return. What does result = add(2, 3) store in result?
A. None ✓
B. 5
print() only shows 5 on the screen. Without a return, the function gives back None, so result holds None.
2. Which function lets you store its answer in a variable and use it later?
A. def double(n): print(n * 2)
B. def double(n): return n * 2 ✓
return hands the value back to the caller. print() only displays it and the function gives back None.
3. What does total = add(2, 3) + 10 do if add() only prints a + b and has no return?
A. It sets total to 15
B. It causes a TypeError, because None + 10 is not allowed ✓
add() gives back None, and Python cannot add None and a number. You need return a + b for this to work.
4. Which line puts the result of square(4) into a variable named answer?
A. answer = square(4) ✓
B. print(square(4)) = answer
A function call that returns a value can be stored with =. This only works if square() uses return.
5. True or false: print() inside a function sends the value back to the line that called it.
A. False ✓
B. True
print() only displays text on the screen. return is what sends the value back to the caller.

Match the Pairs

def add(a, b): return a + b → Hands the sum back to the caller so it can be stored or used in a calculation
def add(a, b): print(a + b) → Only shows the sum on screen, and the function gives back None
Storing the result of a function that returns a value in a variable → total = add(2, 3)
Using a returned result inside a calculation → double = add(2, 3) * 2
def square(n): print(n * n) answer = square(4) + 1 → square() only prints and gives back None, so adding 1 to None causes a TypeError. Use return n * n instead of print(n * n).
def get_age(): print(13) age = get_age() → age is stored as None because get_age() prints 13 but does not return it. Use return 13 instead.

Key Term

return
Hands a value back to the caller so it can be stored in a variable or used in a calculation. print() inside a function only shows the value on screen, and the function then gives back None.

Fill in the Blanks

1. def total(a, b): return a + b print(total(2, 3))
Hint: Type the keyword that hands the sum back to the caller instead of just showing it.
2. def hi(): print("Hi") print(hi() == None)
Hint: Type the special value a function gives back when it has no return statement.
3. def cube(n): return n ** 3 volume = cube(3)
Hint: Type the name of the function defined above so its returned value is stored in the variable.
4. def double(n): return n * 2 print(double(4) + 1)
Hint: Type the keyword that gives the doubled number back so the last line can add 1 to it.
5. def greet(): print("Hello!") greet()
Hint: Type the function that only displays the message on screen, since no value needs to come back.

Spot the Error

Question 1
A def add(a, b):
B print(a + b)
C total = add(2, 3)
D print(total)
Line B — print() only shows the sum on screen and the function then gives back None. So total holds None, not 5. The line should be 'return a + b' so the value is handed back and can be stored.
Question 2
A def to_f(c):
B print(c * 9 / 5 + 32)
C warm = to_f(25) > 70
D print(warm)
Line B — print() shows the temperature but the function returns None. Comparing None > 70 causes a TypeError. Use 'return c * 9 / 5 + 32' so the result can be used in the comparison.
Question 3
A def add_bonus(n):
B return n + 5
C add_bonus(10)
D print(score)
Line C — The returned value is thrown away because it is not stored in a variable. So score is never created and print(score) gives a NameError. It should be 'score = add_bonus(10)'.
Question 4
A def cube(n):
B return n * n * n
C x = cube(3)
D return x
Line D — return can only be used inside a function. Outside one it causes a SyntaxError. To show the value on screen at the main level, use print(x).
Question 5
A def add(a):
B return a + b
C total = add(4, 6)
D print(total)
Line A — The function body uses b, but b is not listed as a parameter, so the call add(4, 6) fails. The line should be 'def add(a, b):' so both values can be passed in and the sum returned.

Student with a class code? Join your class →