GRADE 8 · COMPUTING · UNIT 1 · LESSON 1.31
Computational thinking and programming
Cast to Boolean and validate an empty response
Read a little. Try the workbook. Check your answers. Choose one section below to get started.
LET’S TRACE, REASON AND TEST
Cast to Boolean and validate an empty response
Converting to Boolean tests truthiness, not whether text spells a Boolean literal. Empty text is false; nonempty text is true. An empty-response check is different from checking whether a meaningful valid answer was supplied.
- Explain numeric and string truthiness; use a flag to select an output.
- Explain my method and support it with a labelled trace, example or test record.

Work through an example
bool("") is False, while bool("False") is True because that string is nonempty. A string of spaces is also nonempty unless an explicit strip step removes them first.
Try before your workbook
What is bool("0") in Python, and does that prove the response is a valid number?
Explore the clues
Tap one card to find out more.
Understand the idea
Converting to Boolean tests truthiness, not whether text spells a Boolean literal. Empty text is false; nonempty text is true. An empty-response check is different from checking whether a meaningful valid answer was supplied.
Concept to practise: Cast to Boolean and validate an empty response.
Work through an example
bool("") is False, while bool("False") is True because that string is nonempty. A string of spaces is also nonempty unless an explicit strip step removes them first.
Try before your workbook
What is bool("0") in Python, and does that prove the response is a valid number?
Check my readiness thinking
It is True because the string is nonempty. Truthiness alone does not validate numeric meaning, allowed values or useful content.
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.
Convert a value to a Boolean deliberately
For example, bool("False") is True because the string contains characters. The unquoted Boolean False is different. These rules follow Python truth-value testing.
Recall conversions and keep the resulting type
| Expression | Resulting value | Python type |
|---|---|---|
| int("18") | {'clue': 'Value', 'prompt': 'Value of int("18")', 'answers': ['18']} | {'clue': 'Type', 'prompt': 'Type after int conversion', 'answers': ['int', 'integer']} |
| str(24) | {'clue': 'Quoted value', 'prompt': 'Value of str(24)', 'answers': ['"24"', "'24'"]} | {'clue': 'Type', 'prompt': 'Type after str conversion', 'answers': ['str', 'string']} |
| float("6.25") | {'clue': 'Value', 'prompt': 'Value of float("6.25")', 'answers': ['6.25']} | {'clue': 'Type', 'prompt': 'Type after float conversion', 'answers': ['float', 'real']} |
Predict truthiness for numbers
| Expression | Boolean result |
|---|---|
| bool(0) | {'clue': 'True or False', 'prompt': 'Result of bool(0)', 'answers': ['False']} |
| bool(0.0) | {'clue': 'True or False', 'prompt': 'Result of bool(0.0)', 'answers': ['False']} |
| bool(-4) | {'clue': 'True or False', 'prompt': 'Result of bool(-4)', 'answers': ['True']} |
| bool(7) | {'clue': 'True or False', 'prompt': 'Result of bool(7)', 'answers': ['True']} |
| bool(2.5) | {'clue': 'True or False', 'prompt': 'Result of bool(2.5)', 'answers': ['True']} |
Predict truthiness for strings
| Expression | Boolean result |
|---|---|
| bool("") | {'clue': 'True or False', 'prompt': 'Result of bool("")', 'answers': ['False']} |
| bool("False") | {'clue': 'True or False', 'prompt': 'Result of bool("False")', 'answers': ['True']} |
| bool("0") | {'clue': 'True or False', 'prompt': 'Result of bool("0")', 'answers': ['True']} |
| bool(" ") | {'clue': 'True or False', 'prompt': 'Result of bool(" ")', 'answers': ['True']} |
| bool("True") | {'clue': 'True or False', 'prompt': 'Result of bool("True")', 'answers': ['True']} |
| bool("no") | {'clue': 'True or False', 'prompt': 'Result of bool("no")', 'answers': ['True']} |
Use a stored flag to detect an empty entry
Original Paxa empty-entry check
data = input()
has_data = bool(data)
if not has_data:
print("No entry")
else:
print("Entry received")Trace raw input without trimming it
| Input action/text | has_data | Final message |
|---|---|---|
| Enter only | {'clue': 'True or False', 'prompt': 'Empty input flag', 'answers': ['False']} | {'clue': 'Exact message', 'prompt': 'Empty input message', 'answers': ['No entry']} |
| "Orbit" | {'clue': 'True or False', 'prompt': 'Orbit input flag', 'answers': ['True']} | {'clue': 'Exact message', 'prompt': 'Orbit input message', 'answers': ['Entry received']} |
| "False" | {'clue': 'True or False', 'prompt': 'False word input flag', 'answers': ['True']} | {'clue': 'Exact message', 'prompt': 'False word input message', 'answers': ['Entry received']} |
| One space " " | {'clue': 'True or False', 'prompt': 'Space input flag', 'answers': ['True']} | {'clue': 'Exact message', 'prompt': 'Space input message', 'answers': ['Entry received']} |
Allow one retry after a truly empty line
Original Paxa single-retry version
data = input()
if not bool(data):
print("Try once more")
data = input()
has_data = bool(data)
if has_data:
print("Entry received")
else:
print("No entry")Choose whether whitespace should count
| Stored data | bool(data) | bool(data.strip()) |
|---|---|---|
| "" | {'clue': 'True or False', 'prompt': 'Raw empty', 'answers': ['False']} | {'clue': 'True or False', 'prompt': 'Clean empty', 'answers': ['False']} |
| " " | {'clue': 'True or False', 'prompt': 'Raw space', 'answers': ['True']} | {'clue': 'True or False', 'prompt': 'Clean space', 'answers': ['False']} |
| " Orbit " | {'clue': 'True or False', 'prompt': 'Raw padded word', 'answers': ['True']} | {'clue': 'True or False', 'prompt': 'Clean padded word', 'answers': ['True']} |
| "O r" | {'clue': 'True or False', 'prompt': 'Raw internal space', 'answers': ['True']} | {'clue': 'True or False', 'prompt': 'Clean internal space', 'answers': ['True']} |
Distinguish values that look similar
| Shown value | Python type |
|---|---|
| "Gallery" | {'clue': 'int / float / str / bool', 'prompt': 'Type of "Gallery"', 'answers': ['str', 'string']} |
| 18.75 | {'clue': 'int / float / str / bool', 'prompt': 'Type of 18.75', 'answers': ['float', 'real']} |
| -2048 | {'clue': 'int / float / str / bool', 'prompt': 'Type of -2048', 'answers': ['int', 'integer']} |
| False | {'clue': 'int / float / str / bool', 'prompt': 'Type of False', 'answers': ['bool', 'Boolean']} |
| "1" | {'clue': 'int / float / str / bool', 'prompt': 'Type of "1"', 'answers': ['str', 'string']} |
| "true" | {'clue': 'int / float / str / bool', 'prompt': 'Type of "true"', 'answers': ['str', 'string']} |
Trace a numeric input and a Boolean decision
Original Paxa cost-and-flag check
cost = float(input())
if cost >= 12.0:
affordable = False
else:
affordable = TrueRead a complete original mission gate
Original curriculum module C05
MIN_POINTS = 12
BASE_TOKENS = 40
DISCOUNT_RATE = 0.25
print("Enter a fictional team code, points, and yes/no on separate lines.")
team = input().strip()
points = int(input())
badge_reply = input().strip().lower()
has_team = bool(team)
has_points = points >= MIN_POINTS
has_badge = badge_reply == "yes"
can_enter = has_team and has_points and has_badge
token_cost = BASE_TOKENS
if can_enter:
token_cost = BASE_TOKENS * (1 - DISCOUNT_RATE)
print("Team entered:", has_team)
print("Enough points:", has_points)
print("Badge confirmed:", has_badge)
print("Gate open:", can_enter)
print("Tokens:", token_cost)Identify the mission data types and roles
| Name or group | Python type |
|---|---|
| MIN_POINTS and BASE_TOKENS | {'clue': 'Type', 'prompt': 'Type of mission integer settings', 'answers': ['int', 'integer']} |
| DISCOUNT_RATE | {'clue': 'Type', 'prompt': 'Type of mission discount rate', 'answers': ['float', 'real']} |
| team and badge_reply | {'clue': 'Type', 'prompt': 'Type of mission text inputs', 'answers': ['str', 'string']} |
| points | {'clue': 'Type', 'prompt': 'Type of mission points', 'answers': ['int', 'integer']} |
| has_team, has_points, has_badge, can_enter | {'clue': 'Type', 'prompt': 'Type of mission flags', 'answers': ['bool', 'Boolean']} |
Predict mission boundaries and text handling
| Team | Points | Badge | Gate open | Tokens |
|---|---|---|---|---|
| Orbit | 12 | yes | {'clue': 'True or False', 'prompt': 'Gate open for case 1', 'answers': ['True']} | {'clue': 'Amount', 'prompt': 'Tokens for case 1', 'answers': ['30.0', '30']} |
| Orbit | 11 | yes | {'clue': 'True or False', 'prompt': 'Gate open for case 2', 'answers': ['False']} | {'clue': 'Amount', 'prompt': 'Tokens for case 2', 'answers': ['40', '40.0']} |
| Enter only | 12 | yes | {'clue': 'True or False', 'prompt': 'Gate open for case 3', 'answers': ['False']} | {'clue': 'Amount', 'prompt': 'Tokens for case 3', 'answers': ['40', '40.0']} |
| Orbit | 12 | no | {'clue': 'True or False', 'prompt': 'Gate open for case 4', 'answers': ['False']} | {'clue': 'Amount', 'prompt': 'Tokens for case 4', 'answers': ['40', '40.0']} |
| 3 spaces | 13 | 1 space + YES + 1 space | {'clue': 'True or False', 'prompt': 'Gate open for case 5', 'answers': ['False']} | {'clue': 'Amount', 'prompt': 'Tokens for case 5', 'answers': ['40', '40.0']} |
| 2 spaces + Orbit + 2 spaces | 12 | 1 space + YES + 1 space | {'clue': 'True or False', 'prompt': 'Gate open for case 6', 'answers': ['True']} | {'clue': 'Amount', 'prompt': 'Tokens for case 6', 'answers': ['30.0', '30']} |
Review the five topic skills with evidence
| Skill | Suitable evidence |
|---|---|
| Explain a constant and its purpose | A fixed setting and maintenance explanation |
| Write a program using a constant | One definition used consistently |
| Describe Boolean data | True/False and quoted-text distinction |
| Identify data needing a Boolean | A clearly named yes/no state |
| Create a program using Boolean data | Flag assignment, branch and tested outcomes |
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 16 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.3 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 16 worksheets
Worksheet 1
- Question 1: What does bool() test in these examples? the value’s truthiness
- Question 2: What type is the result returned by bool()? bool
Worksheet 2
- Question 3: Value of int("18") 18
- Question 4: Type after int conversion int / integer
- Question 5: Value of str(24) "24" / '24'
- Question 6: Type after str conversion str / string
- Question 7: Value of float("6.25") 6.25
- Question 8: Type after float conversion float / real
- Question 9: Which conversion preserves the text nature of a result? str()
Worksheet 3
- Question 10: Result of bool(0) False
- Question 11: Result of bool(0.0) False
- Question 12: Result of bool(-4) True
- Question 13: Result of bool(7) True
- Question 14: Result of bool(2.5) True
Worksheet 4
- Question 15: Result of bool("") False
- Question 16: Result of bool("False") True
- Question 17: Result of bool("0") True
- Question 18: Result of bool(" ") True
- Question 19: Result of bool("True") True
- Question 20: Result of bool("no") True
Worksheet 5
- Question 21: Which variable stores the input string? data
- Question 22: Which variable stores a Boolean flag? has_data
- Question 23: What value does has_data store for an empty input line? False
Worksheet 6
- Question 24: Empty input flag False
- Question 25: Empty input message No entry
- Question 26: Orbit input flag True
- Question 27: Orbit input message Entry received
- Question 28: False word input flag True
- Question 29: False word input message Entry received
- Question 30: Space input flag True
- Question 31: Space input message Entry received
Worksheet 7
- Question 32: If both input lines are empty, what is the final message? No entry
- Question 33: If the first input is Orbit, how many input lines are read? 1
Worksheet 8
- Question 34: Raw empty False
- Question 35: Clean empty False
- Question 36: Raw space True
- Question 37: Clean space False
- Question 38: Raw padded word True
- Question 39: Clean padded word True
- Question 40: Raw internal space True
- Question 41: Clean internal space True
Worksheet 9
- Question 42: Type of "Gallery" str / string
- Question 43: Type of 18.75 float / real
- Question 44: Type of -2048 int / integer
- Question 45: Type of False bool / Boolean
- Question 46: Type of "1" str / string
- Question 47: Type of "true" str / string
Worksheet 10
- Question 48: What Python type does cost store? float / real
- Question 49: What Python type does affordable store? bool / Boolean
- Question 50: For cost 11.99, what flag is stored? True
- Question 51: For cost 12.00, what flag is stored? False
Worksheet 11
This page introduces the activity. There are no marked responses on this sheet.
Worksheet 12
- Question 52: Type of mission integer settings int / integer
- Question 53: Type of mission discount rate float / real
- Question 54: Type of mission text inputs str / string
- Question 55: Type of mission points int / integer
- Question 56: Type of mission flags bool / Boolean
Worksheet 13
- Question 57: Gate open for case 1 True
- Question 58: Tokens for case 1 30.0 / 30
- Question 59: Gate open for case 2 False
- Question 60: Tokens for case 2 40 / 40.0
- Question 61: Gate open for case 3 False
- Question 62: Tokens for case 3 40 / 40.0
- Question 63: Gate open for case 4 False
- Question 64: Tokens for case 4 40 / 40.0
- Question 65: Gate open for case 5 False
- Question 66: Tokens for case 5 40 / 40.0
- Question 67: Gate open for case 6 True
- Question 68: Tokens for case 6 30.0 / 30
Worksheet 14
- Question 69: Why can token_cost store int or float in this program? different paths assign 40 or the calculated 30.0
Worksheet 15
- Question 70: Predict and explain the page 5 raw-input check for an empty line, Orbit, False as typed text and one space. Implement the page 7 single-retry version or recreate it in a new file. Test first-line Orbit, empty then Orbit, and empty then empty, showing every message and actual output or Pending. Explain why the flag must be recalculated after a retry. State whether raw spaces count; as an extension use strip() to reject whitespace-only entries and retest. Describe your approach, any correction, actual individual/partner work and what you would improve next time. Raw flags False/True/True/True with No entry/Entry received/Entry received/Entry received. Retry Orbit -> Entry received only; empty then Orbit -> Try once more then Entry received; empty twice -> Try once more then No entry. At most two reads; no infinite/repeat-until-valid claim. Re-evaluate bool after data changes, strings/flags str/bool. Raw space accepted, strip variant rejects whitespace-only but retains internal spaces. Complete source/tests, prediction/actual or Pending, corrections/retests, truthful roles and reflective next step. No personal names or invented partner evidence required. Grown-up review; personal evidence is required.
Worksheet 16
- Question 71: Use the complete original page 11 C05 program. Identify every constant, input, flag and calculated value, with its type and purpose. Predict all four flags, token amount and full output for the six page 13 cases, then run if available or mark actual results Pending. Change MIN_POINTS to 15 between runs and test Orbit/yes at points 14 and 15, explaining which flag and output change. Keep full code, dictionary, test records and corrections. Reflect on the five page 14 skills with one evidence-based success and one next step. Fixed MIN_POINTS = 12 (int), BASE_TOKENS = 40 (int), DISCOUNT_RATE = 0.25 (float); team/badge_reply str, points int; four bool flags; token_cost is 40 (int) or 30.0 (float). Conditions team nonempty after strip, points>=threshold, normalised badge==yes; conjunction all required. Original six cases open True,False,False,False,False,True; tokens30.0,40,40,40,40,30.0. Exact instruction plus five result labels and values as source; complete four flags in records. New threshold 15: Orbit/14/yes -> has_team True,has_points False,has_badge True,can_enter False,tokens40; at 15 all True, tokens 30.0. Complete code/dictionary/predictions/actual or Pending/correction/retest, no learner grading or hardware assertion. Five skills reflection cites real evidence and next step. Grown-up review; personal evidence is required.
Curriculum & workbook reference
- Cambridge Lower Secondary Computing Learner’s Book 8 — pages 122–124
- PaxaKids Grade 8 Computing Lesson 1.31: Cast to Boolean and validate an empty response — pages 1–16
Computing for your homeschool day
Explore Cast to Boolean and validate an empty response 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.
