← VCE Software Development U4O1

Procedures versus functions

A procedure carries out a task without returning a value, while a function returns a value to the code that called it, so the result can be stored or used.

Understanding Procedures versus functions in VCE Software Development U4O1

What it does: The call add(2, 3) gives back a value, which is stored in total. This only works with a function that returns a value. A procedure does not return a value, so it is simply called on its own line to carry out its task. Having a parameter does not make something a function. show_welcome only prints, so it is a procedure. If the result must be used later, return it from a function. Printing only shows it on screen. A function's returned value is lost unless the caller stores it in a variable or uses it, for example by printing it.

Common mistakes: say_hi is a procedure that should print its message. With return, the text goes back to the caller, which does nothing with it, so nothing is shown. It should be print("Hi, " + name). A function must send its answer back to the caller. A bare return gives back None, so print() would show None instead of 12. It should be return 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
Which best describes a procedure?
It always sends a value back to the code that called itIt carries out a task, such as printing, without returning a value
Matches
def area(w, h): print(w * h) size = area(3, 4)
↓
area only prints and has no return, so it is a procedure. size stores None, not 12. Use return w * h to make it a function.
Applying
Meanings
Term
procedure vs function
Meaning
A procedure carries out a task without returning a value, while a function returns a value to the code that called it, so the result can be stored or used.
Practice
def show_total(a, b):
Testing
Gaps
(a + b)
Check Answer
Spots
1def say_hi(name):
2 return "Hi, " + name

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

The 'Firefly' badge — Night Coder, 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 best describes a procedure?
A. It carries out a task, such as printing, without returning a value ✓
B. It always sends a value back to the code that called it
A procedure does a job (like displaying a message) but does not hand a value back to the caller.
2. Which best describes a function?
A. It returns a value to the code that called it ✓
B. It can never be used inside an expression or stored in a variable
A function returns a value, so the caller can store it in a variable or use it in a calculation.
3. Which of these is a procedure? def show_welcome(name): print("Welcome,", name)
A. show_welcome, because it only prints and has no return ✓
B. show_welcome, because it has a parameter
Having a parameter does not make something a function. show_welcome only prints, so it is a procedure.
4. Which of these is a function?
A. def say_hi(): print("Hi")
B. def double(n): return n * 2 ✓
double uses return to send a value back. say_hi only prints, so it is a procedure.
5. Which line stores the result of a call in a variable?
A. total = show_message("Hi") # show_message only prints
B. total = add(3, 4) # add returns a value ✓
Only a function returns a value to store. A procedure that only prints gives back nothing useful to keep.

Match the Pairs

def show_menu(): print("1. Play") → A procedure: it carries out a task (printing) but does not return a value to the caller
def add(a, b): return a + b → A function: it sends a value back to the code that called it so the result can be stored or used
A function's returned value can be stored in a variable for later use → total = add(2, 3)
A procedure is called as its own statement because it has no result to store → show_menu()
def area(w, h): print(w * h) size = area(3, 4) → area only prints and has no return, so it is a procedure. size stores None, not 12. Use return w * h to make it a function.
def greet(name): return "Hi " + name greet("Sam") → greet returns a value but the result is never printed or stored, so nothing is shown. Use print(greet("Sam")) or store it in a variable.

Key Term

procedure vs function
A procedure carries out a task without returning a value, while a function returns a value to the code that called it, so the result can be stored or used.

Fill in the Blanks

1. def showTotal(a, b): print(a + b)
Hint: Type the built-in that displays output on screen, which is what makes this a procedure that prints.
2. def add(a, b): return a + b
Hint: Type the keyword that sends a value back to the code that called the function.
3. def add(a, b): return a + b total = add(2, 3)
Hint: Type the name of the function being called so its returned value is stored in total.
4. def showMenu(): print("1. Play") print("2. Quit")
Hint: Type the keyword that starts the definition of a procedure.
5. def showArea(w, h): print(w * h) showArea(3, 4)
Hint: Type the procedure name used to call it as a statement, without storing a result.

Spot the Error

Question 1
A def say_hi(name):
B return "Hi, " + name
C say_hi("Ava")
Line B — say_hi is a procedure that should print its message. With return, the text goes back to the caller, which does nothing with it, so nothing is shown. It should be print("Hi, " + name).
Question 2
A def area(w, h):
B result = w * h
C return
D print(area(3, 4))
Line C — A function must send its answer back to the caller. A bare return gives back None, so print() would show None instead of 12. It should be return result.
Question 3
A def show_menu():
B print("1. Play")
C print("2. Quit")
D show_menu
Line D — Without brackets the procedure is only named, not called, so its code never runs and nothing prints. It should be show_menu().
Question 4
A def square(n):
B n * n
C answer = square(5)
D print(answer)
Line B — The multiplication is worked out but never returned. The function gives back None, so answer would be None. It should be return n * n.
Question 5
A def get_double(n)
B return n * 2
C print(get_double(4))
Line A — A function definition header must end with a colon. It should be def get_double(n):.

Student with a class code? Join your class →