GRADE 8 · COMPUTING · UNIT 1 · LESSON 1.27
Computational thinking and programming
Set and use Boolean flags
Read a little. Try the workbook. Check your answers. Choose one section below to get started.
LET’S TRACE, REASON AND TEST
Set and use Boolean flags
A Boolean flag records a true-or-false state. Assign and update it deliberately; a comparison can produce its value. Use the flag to explain why a later conditional action runs.
- Trace comparisons, store results in flags and combine flags in a quiz.
- Explain my method and support it with a labelled trace, example or test record.

Work through an example
Set packed = False, then packed = (count == required). For count 5 and required 5, packed becomes True because the equality comparison succeeds.
Try before your workbook
If count is 4 and required is 5, what value should that flag hold?
Explore the clues
Tap one card to find out more.
Understand the idea
A Boolean flag records a true-or-false state. Assign and update it deliberately; a comparison can produce its value. Use the flag to explain why a later conditional action runs.
Concept to practise: Set and use Boolean flags.
Work through an example
Set packed = False, then packed = (count == required). For count 5 and required 5, packed becomes True because the equality comparison succeeds.
Try before your workbook
If count is 4 and required is 5, what value should that flag hold?
Check my readiness thinking
False. The flag reflects the comparison result; it is not the text "False" or the count itself.
Your original programs and learning models
These original PaxaKids program and data models support your workbook. Some examples deliberately contain faults to investigate. Follow their headings and preserve exact code case, punctuation and order. Traces and supplied records are not claims of physical testing.
Store a condition as a Boolean flag
Use meaningful names and genuine True/False values. The stored flag can be tested later without rewriting the full comparison every time.
Trace a flag that begins False
Original Paxa readiness-flag program
ready = False
pieces = 15
if pieces >= 12:
ready = True
print(ready)Change the number and retest the boundary
| Pieces | Stored ready before print |
|---|---|
| 0 | {'clue': 'True or False', 'prompt': 'Ready for 0 pieces', 'answers': ['False']} |
| 11 | {'clue': 'True or False', 'prompt': 'Ready for 11 pieces', 'answers': ['False']} |
| 12 | {'clue': 'True or False', 'prompt': 'Ready for 12 pieces', 'answers': ['True']} |
| 15 | {'clue': 'True or False', 'prompt': 'Ready for 15 pieces', 'answers': ['True']} |
Compare an IF/ELSE with direct comparison assignment
A: explicit assignment blocks
pieces = int(input())
if pieces >= 12:
ready = True
else:
ready = FalseB: store comparison result
pieces = int(input())
ready = pieces >= 12Use a Boolean flag with valid Python syntax
A: direct Boolean test
ready = True
if ready:
print("Ready")B: explicit comparison
ready = True
if ready == True:
print("Ready")Trace two quiz flags and combine them
Original Paxa two-question flag quiz
print("What is 3 * 4?")
first = int(input())
if first == 12:
correct1 = True
else:
correct1 = False
print("What is 21 / 3?")
second = int(input())
if second == 7:
correct2 = True
else:
correct2 = False
if correct1 and correct2:
print("Both match")
elif correct1 or correct2:
print("One matches")
else:
print("Neither matches")Complete all four two-flag combinations
| First | Second | Flag A | Flag B | Feedback |
|---|---|---|---|---|
| 12 | 7 | {'clue': 'True or False', 'prompt': 'First flag for 12/7', 'answers': ['True']} | {'clue': 'True or False', 'prompt': 'Second flag for 12/7', 'answers': ['True']} | {'clue': 'Final message', 'prompt': 'Quiz feedback for 12/7', 'answers': ['Both match']} |
| 11 | 7 | {'clue': 'True or False', 'prompt': 'First flag for 11/7', 'answers': ['False']} | {'clue': 'True or False', 'prompt': 'Second flag for 11/7', 'answers': ['True']} | {'clue': 'Final message', 'prompt': 'Quiz feedback for 11/7', 'answers': ['One matches']} |
| 12 | 8 | {'clue': 'True or False', 'prompt': 'First flag for 12/8', 'answers': ['True']} | {'clue': 'True or False', 'prompt': 'Second flag for 12/8', 'answers': ['False']} | {'clue': 'Final message', 'prompt': 'Quiz feedback for 12/8', 'answers': ['One matches']} |
| 11 | 8 | {'clue': 'True or False', 'prompt': 'First flag for 11/8', 'answers': ['False']} | {'clue': 'True or False', 'prompt': 'Second flag for 11/8', 'answers': ['False']} | {'clue': 'Final message', 'prompt': 'Quiz feedback for 11/8', 'answers': ['Neither matches']} |
Identify the quiz data and stored results
| Variable | Meaning | Python type |
|---|---|---|
| first | First numeric answer | {'clue': 'int or bool', 'prompt': 'Type of first', 'answers': ['int', 'integer']} |
| second | Second numeric answer | {'clue': 'int or bool', 'prompt': 'Type of second', 'answers': ['int', 'integer']} |
| correct1 | Whether first equals 12 | {'clue': 'int or bool', 'prompt': 'Type of correct1', 'answers': ['bool', 'Boolean']} |
| correct2 | Whether second equals 7 | {'clue': 'int or bool', 'prompt': 'Type of correct2', 'answers': ['bool', 'Boolean']} |
Plan a third question and four feedback outcomes
| Matching flags | Feedback |
|---|---|
| All three true | Every answer matches |
| Exactly two true | A pair matches |
| Exactly one true | One answer matches |
| All three false | No answers match |
Reflect with a consistent labelled scale
| Description | Evidence-based meaning |
|---|---|
| Ready independently | I can explain and change flag programs using evidence. |
| Mostly ready | I can do most parts with occasional prompts. |
| Partly ready | Some parts are clear; I can name what needs practice. |
| Beginning | I understand a few parts and need guided practice. |
| Need support | I need help to trace or create the flags accurately. |
Files for this activity
Use these original PaxaKids practice files with the matching workbook. Work on a local copy in the appropriate editor. Some examples deliberately contain faults to investigate; a downloaded file is not a completed practical test.

Try one step with Paxa!
Trace code in the stated order and preserve exact spelling and case. Use fictional data. Label a prediction, paper trace, simulator run and physical-device test separately; an unperformed test stays Pending. Save personal responses before leaving.
Our Unit 1 learning path
- Lesson 1.1: Recall algorithms and representations
- Lesson 1.2: Purpose and conventions of pseudocode
- Lesson 1.3: Input, output and strings
- Lesson 1.4: Identifiers and assignment
- Lesson 1.5: Arithmetic and translation
- Lesson 1.6: Trace and review a sequence
- Lesson 1.7: Conditions and two-way flow
- Lesson 1.8: IF THEN and indentation
- Lesson 1.9: IF THEN ELSE and decision diagrams
- Lesson 1.10: Ordered ELSEIF and fallback ELSE
- Lesson 1.11: Match flowchart and pseudocode branches
- Lesson 1.12: AND, OR and NOT
- Lesson 1.13: Grouping, precedence and review
- Lesson 1.14: Why software searches
- Lesson 1.15: A successful linear search
- Lesson 1.16: An unsuccessful search and termination
- Lesson 1.17: Practise and communicate the search
- Lesson 1.18: Translate conditions into Python
- Lesson 1.19: One-branch IF programs
- Lesson 1.20: Two-way IF ELSE programs
- Lesson 1.21: Ordered ELIF choices
- Lesson 1.22: Ranges and independent decisions
- Lesson 1.23: Boolean operators in Python
- Lesson 1.24: Design and test recommendations
- Lesson 1.25: Trace, debug and reflect
- Lesson 1.26: Choose data types and recognise Boolean literals
- Lesson 1.27: Set and use Boolean flags
- Lesson 1.28: Explain and identify constants
- Lesson 1.29: Express constants in three algorithm forms
- Lesson 1.30: Use a fixed factor in a calculation
- Lesson 1.31: Cast to Boolean and validate an empty response
- Lesson 1.32: Recall calls and trace return values
- Lesson 1.33: Supply parameters and reuse library code
- Lesson 1.34: Choose and import libraries responsibly
- Lesson 1.35: Round with floor and ceiling
- Lesson 1.36: Use pi and investigate another mathematical feature
- Lesson 1.37: Generate random choices within bounds
- Lesson 1.38: Investigate random real values and review library use
- Lesson 1.39: Retrieve test tables and predict selection outcomes
- Lesson 1.40: Decompose everyday problems
- Lesson 1.41: Decompose programs and organise shared work
- Lesson 1.42: Develop through repeated build/test cycles
- Lesson 1.43: Predict and verify algorithm outcomes
- Lesson 1.44: Choose representative and boundary tests
- Lesson 1.45: Build, execute and review a test plan
- Lesson 1.46: Recall physical inputs and compare transmission media
- Lesson 1.47: Configure a radio group and agree a message scheme
- Lesson 1.48: Send and receive numbers and strings
- Lesson 1.49: Trace numeric message sequences
- Lesson 1.50: Transmit text and use received data in conditions
- Lesson 1.51: Diagnose and extend a message protocol
- Lesson 1.52: Review communication and evidence of testing
- Lesson 1.53: Project 1: Adventure story
- Lesson 1.54: Project 2: Fire, Water, Earth
- Lesson 1.55: Check your progress 1
For grown-ups: using this lesson
Your answers are checked in your browser. Open responses need grown-up review and are shown separately from the automatic score. Check your work, then use “Retry answers to practise” to revisit mistakes while keeping correct responses.
Read one explanation, discuss the model and try the readiness check before the workbook. Choose “Mark lesson finished” when ready. Optional account progress saves lesson position and completion across devices; save personal responses before leaving.
2. Fill in your workbook
Read the teaching and complete workbook instructions. Choose, write or draw; Answer list offers larger controls. Trace code precisely and distinguish predictions from actual tests. Review designs, explanations and drawings with a grown-up.
Opening your PDF…
Swipe sideways across the worksheet on a small screen, or use “Answer list” for larger controls.
You’ve completed the checked activities.
TAKE YOUR PRACTICE OFFLINE
3. Download the student worksheet
All 12 original A4 student pages, ready for pencil-and-paper practice. Choose Review Answers to check your work on this webpage.
Student worksheet only · PDF · 8.5 MiB · No answer key included
TRY FIRST, THEN CHECK TOGETHER
Download the student worksheet →4. Answers & guidance
Finished your try? Open the guide and compare one worksheet at a time. Your own words may be different and still explain the right idea.
Shown on this webpage only. There is no answer-key download, and this guide is left out when printing the page.
Show answers for all 12 worksheets
Worksheet 1
- Question 1: Which is a meaningful name for a Boolean readiness state? ready
- Question 2: What type should a flag have in these examples? bool
Worksheet 2
- Question 3: What integer is stored in pieces as shown? 15
- Question 4: What value is stored in ready immediately before print? True
- Question 5: What does the program print? True
Worksheet 3
- Question 6: Ready for 0 pieces False
- Question 7: Ready for 11 pieces False
- Question 8: Ready for 12 pieces True
- Question 9: Ready for 15 pieces True
- Question 10: Which variable is Boolean in the program? ready
Worksheet 4
- Question 11: For input 11, do the versions store the same flag? yes, both store False
- Question 12: If pieces changes later, does stored ready automatically recalculate? no, the comparison must be evaluated again to update it
Worksheet 5
- Question 13: Which shown forms are valid for this Boolean flag? A and B
- Question 14: Repair the invalid header if ready = True: using either valid form. if ready: / if ready == True:
- Question 15: Which representation should ready store here? True without quotes
Worksheet 6
This page introduces the activity. There are no marked responses on this sheet.
Worksheet 7
- Question 16: First flag for 12/7 True
- Question 17: Second flag for 12/7 True
- Question 18: Quiz feedback for 12/7 Both match
- Question 19: First flag for 11/7 False
- Question 20: Second flag for 11/7 True
- Question 21: Quiz feedback for 11/7 One matches
- Question 22: First flag for 12/8 True
- Question 23: Second flag for 12/8 False
- Question 24: Quiz feedback for 12/8 One matches
- Question 25: First flag for 11/8 False
- Question 26: Second flag for 11/8 False
- Question 27: Quiz feedback for 11/8 Neither matches
Worksheet 8
- Question 28: Type of first int / integer
- Question 29: Type of second int / integer
- Question 30: Type of correct1 bool / Boolean
- Question 31: Type of correct2 bool / Boolean
- Question 32: What does correct1 and correct2 require? both stored Boolean flags to be true
Worksheet 9
- Question 33: Why must all-three be checked before any matching pair? all-three also contains a matching pair
- Question 34: How many True/False combinations exist for three flags? 8
Worksheet 10
- Question 35: Which is useful evidence for a confidence description? a correct boundary trace and explanation of a change
Worksheet 11
- Question 36: Modify the readiness example to read a valid nonnegative integer pieces value. Store whether it is at least 12 in a Boolean ready flag. Then use the flag to print Ready to build for True or Collect more pieces for False. Show either explicit if/else flag assignment or direct comparison assignment, followed by a valid flag test. Test 0, 11, 12 and 15 with predictions and actual output or Pending. Explain the types of pieces and ready and why a later change to pieces would require recalculating ready. Cite full code and tests if saved. Integer input, ready bool from pieces >= 12 via complete if/else or direct assignment, if ready: or if ready == True: with colon/four spaces and defined opposite feedback. Inputs 0/11 -> Collect more pieces;12/15 -> Ready to build. Types int/bool distinct, flag stores evaluated state and is not a live formula; recompute after changing pieces if updated state needed. Full source and exact prediction/actual or Pending evidence, correction/retest if any, no real hardware or learner GUI claim and no numeric marks. Grown-up review; personal evidence is required.
Worksheet 12
- Question 37: Extend the complete page 6 quiz with the page 9 third question and a Boolean correct3 flag. Implement all four feedback outcomes in their stated order without numeric scores. Identify every answer variable and flag with its Python type. Test all eight planned input combinations in the supplied record, predicting flags and final feedback before actual output or Pending. Keep full source and records, explain any correction and retest, and choose a page 10 confidence description supported by evidence. Describe actual individual or partner work and one next step honestly. Three questions expected answers 12,7,5; all answer variables int, three flags bool. First test all flags with and; then any pair: (c1 and c2) or (c1 and c3) or (c2 and c3); then any single with or; else none. Feedback Every answer matches/A pair matches/One answer matches/No answers match, no numerical grade. All eight planned combinations tested, exact flags and output agree, full source/predictions/actual or Pending, correction/retest evidence. Equivalent consistent logic accepted, no arbitrary truthy strings. Confidence description in stated strongest-to-support order with real evidence/help, truthful peer stage and next step. Grown-up review; personal evidence is required.
Curriculum & workbook reference
- Cambridge Lower Secondary Computing Learner’s Book 8 — pages 110–112
- PaxaKids Grade 8 Computing Lesson 1.27: Set and use Boolean flags — pages 1–12
Computing for your homeschool day
Explore Set and use Boolean flags with this free Grade 8 Computing lesson. Read one idea together, try the fillable workbook and return to review at your own pace. Download the same student worksheet PDF for pencil-and-paper practice.
Fit learning around your family’s day. There is no timer and no sign-up is needed to use the lesson. An optional account saves your lesson position and completion across devices. Workbook responses and drawings stay in this tab; save a copy of your responses before leaving.
Understand your results
Closed answers are checked in your browser. Drawings and written explanations need grown-up review and are shown separately from the automatic score. Check your work, then use “Retry answers to practise” to revisit mistakes while keeping correct responses.
Choose Review Answers after trying the activity. The guide stays on the webpage; the worksheet download contains only the student pages.
For programme background, visit the Cambridge Lower Secondary Computing overview. PaxaKids provides independent original companion practice.
Book page references identify the related teaching topic. File-management and responsible-data preparation are original PaxaKids material; orientation or contents pages are not presented as teaching citations for those skills. The explanations, characters, programs and exercises here are original PaxaKids companion practice. Practical tasks require the appropriate editor and, where applicable, suitable equipment. A design or paper trace is not a verified hardware result. Only completed, reviewed lessons are listed.
Explore the Cambridge Lower Secondary Computing curriculum for programme background. PaxaKids is an independent learning resource.
