← ACARA Digital Technologies Years 9–10

Testing compound conditions with and, or, not

A table listing every True/False combination of the parts in an and/or/not condition. Use it to pick test inputs that make each part True and False, then check each result.

Understanding Testing compound conditions with and, or, not in ACARA Digital Technologies Years 9–10

What it does: This expression is one row of the and truth table, and its result is False because and needs both parts True. Each part can be True or False, so 2 x 2 = 4 combinations. Testing only 2 would miss cases. not True is False, so False and True gives False. An and versus or error is found by testing a value outside the range, which should be rejected but is accepted. Boundary tests on each part of a range condition show whether the comparison operators include the limits.

Common mistakes: A truth table needs each part to be True and False in turn. [True, True] never tests a as False, so half the rows are missing. It should be [True, False]. The beach needs both parts True, so the condition must use and. With or, sunny True and warm False wrongly gives True. It should be if sunny and warm:.

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 536–590) and word search (Modules 536–622).

Take this worksheet further — free with Cloodit

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

Learning
Duo
A program checks: if age >= 13 and age <= 19. Which test inputs make EACH part True and False in turn?
age = 10, 15 and 25age = 14, 15 and 16
Matches
if age >= 13 or age <= 19:
↓
Using or instead of and makes the condition True for every number, so even 5 or 50 pass. A test with age 5 would expose the error. It should use and.
Applying
Meanings
Term
truth table
Meaning
A table listing every True/False combination of the parts in an and/or/not condition. Use it to pick test inputs that make each part True and False, then check each result.
Practice
def is_teen(age):
Testing
Gaps
print(True False) # False
Check Answer
Spots
1for a in [True, True]:
2 for b in [True, False]:

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

The 'Sea Dragon' badge — OOP Pioneer, 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 program checks: if age >= 13 and age <= 19. Which test inputs make EACH part True and False in turn?
A. age = 14, 15 and 16
B. age = 10, 15 and 25 ✓
10 makes the first part False, 15 makes both True, and 25 makes the second part False. Using 14, 15 and 16 only tests the True case.
2. A compound condition has two parts joined by and. How many True/False combinations are in its truth table?
A. 2
B. 4 ✓
Each part can be True or False, so 2 x 2 = 4 combinations. Testing only 2 would miss cases.
3. For the condition: has_ticket and has_id, when is the result True?
A. Only when both parts are True ✓
B. When at least one part is True
and needs BOTH parts True. 'At least one' describes or.
4. A student wants the discount if a customer is a member OR spends over $50. A tester uses member = False and spend = 20. What result should the truth table give?
A. False ✓
B. True
Both parts are False, and False or False is False, so no discount.
5. A program should only open the door if code_ok is True and time_ok is True, but the code uses or. Which test finds the error?
A. code_ok = True, time_ok = False (door should stay shut) ✓
B. code_ok = True, time_ok = True (door should open)
With or the door wrongly opens for True/False. The True/True test passes with both operators, so it can't reveal the and versus or error.

Match the Pairs

age >= 13 and age <= 19 → A range condition that is only True when both parts are True, so test 12, 13, 19 and 20 to check each boundary
day == "Sat" or day == "Sun" → A compound condition that is True when at least one part is True, so it is False only when both parts are False
A truth table row tests one combination of the parts. For A=True and B=False, the and result should be False. → True and False
Using not flips a result, so a test must check that True becomes False and False becomes True → not (score > 50)
if age >= 13 or age <= 19: → Using or instead of and makes the condition True for every number, so even 5 or 50 pass. A test with age 5 would expose the error. It should use and.
if age > 13 and age < 19: → The boundary values 13 and 19 are wrongly rejected because > and < were used. It should be >= and <=. Testing 13 and 19 finds the error.

Key Term

truth table
A table listing every True/False combination of the parts in an and/or/not condition. Use it to pick test inputs that make each part True and False, then check each result.

Fill in the Blanks

1. print(True and False) # False
Hint: Type the operator that gives True only when both parts are True.
2. age = 17 if age >= 13 and age <= 17: print("Teen")
Hint: Type the comparison operator for the upper limit that still lets the boundary value pass.
3. raining = True if not raining: print("Walk")
Hint: Type the operator that flips True to False.
4. age = 13 ok = age >= 13 and age <= 17 print(ok)
Hint: Type the variable name that stores the result of the compound condition.
5. score = 120 if score < 0 or score > 100: print("Invalid")
Hint: Type the operator that makes the score invalid if either limit is broken.

Spot the Error

Question 1
A for a in [True, True]:
B for b in [True, False]:
C print(a, b, a and b)
Line A — A truth table needs each part to be True and False in turn. [True, True] never tests a as False, so half the rows are missing. It should be [True, False].
Question 2
A sunny = True
B warm = False
C if sunny or warm:
D print('Beach')
Line C — The beach needs both parts True, so the condition must use and. With or, sunny True and warm False wrongly gives True. It should be if sunny and warm:.
Question 3
A x = 10
B lo = 5
C hi = 10
D ok = lo <= x and x < hi
E print(ok)
Line D — The range includes the upper boundary, so 10 should give True. Using < excludes hi and the boundary test fails. It should be x <= hi.
Question 4
A p = True
B q = False
C result = not (p and q)
D assert result == False
Line D — The truth table says True and False gives False, so not (False) is True. The assert should expect True, not False.
Question 5
A is_weekend = False
B is_holiday = True
C if is_weekend and is_holiday:
D print('No school')
Line C — No school should happen if either part is True, so the condition needs or. With and, a holiday on a weekday would wrongly print nothing. It should be if is_weekend or is_holiday:.

Student with a class code? Join your class →