← ACARA Digital Technologies Years 9–10

Functions that return True or False (Python)

Calls a function that returns True or False and uses that result directly as the if condition. You do not need to write == True. It can also be combined with not, and, or.

Understanding Functions that return True or False (Python) in ACARA Digital Technologies Years 9–10

What it does: age >= 18 already evaluates to True or False, so returning it directly is the simplest way to write the function. Each call gives True or False, so and and not can join them just like ordinary Boolean values. not goes before the function call. Writing it after is a syntax error. A Boolean function must return its value so that if or while can test the result of the call.

Common mistakes: A single = assigns a value and is not allowed inside a return comparison. Use == to compare: return n % 2 == 0. An if statement must end with a colon, even when its condition is a function call that returns True or False. It should be if is_adult(age):.

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 is the cleaner way to use a Boolean function as an if condition?
if is_even(n) == True:if is_even(n):
Matches
if is_even(n) == True: print("Even")
↓
Comparing the result to True is unnecessary. The function already returns a Boolean, so write if is_even(n): instead.
Applying
Meanings
Term
if is_even(n):
Meaning
Calls a function that returns True or False and uses that result directly as the if condition. You do not need to write == True. It can also be combined with not, and, or.
Practice
def is_even(n):
Testing
Gaps
return age 18
Check Answer
Spots
1def is_even(n):
2 return n % 2 = 0

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

The 'Nautilus' badge — Default Expert, 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 is the cleaner way to use a Boolean function as an if condition?
A. if is_even(n): ✓
B. if is_even(n) == True:
is_even(n) already returns True or False, so it can be the condition on its own. Adding == True is unnecessary.
2. Which function correctly returns a comparison result?
A. def is_adult(age): return age >= 18 == "True"
B. def is_adult(age): return age >= 18 ✓
age >= 18 already evaluates to True or False, so you can return it directly. Comparing it to the string "True" gives the wrong result.
3. is_even(7) returns False. What does if not is_even(7): do?
A. Runs the indented code, because not False is True ✓
B. Skips the indented code, because the function returned False
not flips the Boolean. not False becomes True, so the if block runs.
4. Which line correctly checks that BOTH conditions are true using Boolean functions?
A. if is_even(n) and is_positive(n): ✓
B. if is_even(n) and is_positive:
is_positive needs its brackets and argument to be called. Without (n) you are only naming the function, not calling it, so it is not a real True/False check.
5. Which while loop keeps going as long as the number is NOT even?
A. while is_even(n) not:
B. while not is_even(n): ✓
not goes before the function call. Writing it after is a syntax error.

Match the Pairs

def is_even(n): return n % 2 == 0 → Defines a Boolean function that returns True when n is even and False when it is odd.
if is_even(n): → Calls a function that returns True or False and uses the result directly as the if condition.
A Boolean function can return the result of a comparison directly, with no if needed → def is_adult(age): return age >= 18
Boolean functions can be combined in one condition with not, and, or → if is_even(n) and not is_negative(n):
if is_even(n) == True: print("Even") → Comparing the result to True is unnecessary. The function already returns a Boolean, so write if is_even(n): instead.
def is_even(n): print(n % 2 == 0) → The function prints the result instead of returning it, so the call gives None and an if cannot use it. Use return instead of print.

Key Term

if is_even(n):
Calls a function that returns True or False and uses that result directly as the if condition. You do not need to write == True. It can also be combined with not, and, or.

Fill in the Blanks

1. def adult(age): return age >= 18 print(adult(20))
Hint: Type the comparison operator that means 'at least', so the function returns True or False.
2. def even(n): return n % 2 == 0 if even(8): print('Even number')
Hint: Type the name of the Boolean function that is called directly as the if condition, with no == True needed.
3. def even(n): return n % 2 == 0 if not even(7): print('Odd')
Hint: Type the Boolean keyword that flips the True or False result of the function call.
4. def adult(age): return age >= 18 ticket = True if adult(20) and ticket: print('Enter')
Hint: Type the Boolean keyword that needs both the function result and the variable to be True.
5. def even(n): return n % 2 == 0 n = 7 while not even(n): n += 1
Hint: Type the loop keyword that keeps repeating its block as long as the Boolean condition is True.

Spot the Error

Question 1
A def is_even(n):
B return n % 2 = 0
C if is_even(4):
D print('Even')
Line B — A single = assigns a value and is not allowed inside a return comparison. Use == to compare: return n % 2 == 0.
Question 2
A def is_adult(age):
B return age >= 18
C age = 20
D if is_adult(age)
E print('Adult')
Line D — An if statement must end with a colon, even when its condition is a function call that returns True or False. It should be if is_adult(age):
Question 3
A def is_even(n):
B return n % 2 == 0
C if !is_even(7):
D print('Odd')
Line C — Python does not use ! for negation. Put the word not in front of the Boolean function call: if not is_even(7):
Question 4
A def is_pass(mark):
B print(mark >= 50)
C if is_pass(65):
D print('Pass')
Line B — The function prints the comparison instead of returning it, so it gives back None and the if never sees True. It should be return mark >= 50.
Question 5
A def is_vowel(ch):
B return ch in 'aeiou'
C word = 'apple'
D if is_vowel[word[0]]:
E print('Vowel')
Line D — A function is called with round brackets, not square brackets. It should be if is_vowel(word[0]):

Student with a class code? Join your class →