Counting items that meet a compound condition
Inside a loop, an IF with AND or OR tests each item and adds 1 to count only when the whole combined condition is true, so count ends as the number of items that qualify.
Understanding Counting items that meet a compound condition in ACARA Digital Technologies Years 9–10
What it does: NOT reverses the blank test, so count goes up only for items that have something in them. count starts at 0 before the loop, then the IF inside the loop adds 1 for each qualifying mark. AND needs both parts true. With OR, a mark like 120 or -5 would still be counted, because one part is true. One day cannot be both Saturday and Sunday, so AND is never true and count stays at 0. OR is true when either day matches. Starting at 0 means nothing has been counted yet. Starting at 1 makes the final total one too high.
Common mistakes: The counter must start at 0 before the loop. Starting at 1 makes the final count one too high. It should be count ← 0. Each Saturday (6) or Sunday (7) entry should add 1 to count, not take 1 away. The line should be count ← count + 1.
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 492–534) and word search (Modules 459–534).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
IF mark >= 50 AND mark <= 100 THEN count ← count + 1Fill in the Blanks
Spot the Error
Student with a class code? Join your class →