GRADE 8 · COMPUTING · UNIT 1 · LESSON 1.20
Computational thinking and programming
Two-way IF ELSE programs
Read a little. Try the workbook. Check your answers. Choose one section below to get started.
LET’S TRACE, REASON AND TEST
Two-way IF ELSE programs
Use IF/ELSE when exactly one of two alternatives should run. Keep both branch bodies aligned correctly and check the meaning of the comparison at its boundary.
- Align if/else headers, indent their actions and test both branches including equal numbers and exact text.
- Explain my method and support it with a labelled trace, example or test record.

Work through an example
For if items >= 4: print("Box") else: print("Bag"), items 4 prints Box. The ELSE handles cases where the first comparison is false.
Try before your workbook
What does items 3 print under this rule, and does it also print Box?
Explore the clues
Tap one card to find out more.
Understand the idea
Use IF/ELSE when exactly one of two alternatives should run. Keep both branch bodies aligned correctly and check the meaning of the comparison at its boundary.
Concept to practise: Two-way IF ELSE programs.
Work through an example
For if items >= 4: print("Box") else: print("Bag"), items 4 prints Box. The ELSE handles cases where the first comparison is false.
Try before your workbook
What does items 3 print under this rule, and does it also print Box?
Check my readiness thinking
It prints Bag only. A single IF/ELSE decision selects one branch, not both.
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.
Choose one of two outcomes
The headers if and else line up. Each branch has its own indented actions. There is no condition after else, but its header still ends with a colon.
Read aligned headers and two indented blocks
Original Paxa club-card quiz
print("Which club does fictional Mira choose?")
answer = input()
if answer == "drama":
print("You matched the club card")
else:
print("The club card says drama")
print("Question finished")Trace exact text, including capitalisation
| Input text | Branch message: Matched or Card |
|---|---|
| drama | {'clue': 'Matched or Card', 'prompt': 'Branch message for drama', 'answers': ['Matched']} |
| Drama | {'clue': 'Matched or Card', 'prompt': 'Branch message for Drama', 'answers': ['Card']} |
| music | {'clue': 'Matched or Card', 'prompt': 'Branch message for music', 'answers': ['Card']} |
| DRAMA | {'clue': 'Matched or Card', 'prompt': 'Branch message for DRAMA', 'answers': ['Card']} |
Investigate blocks and plan your modifications
Follow two clear routes through the decision

Read this model’s labels and values
- Before
- input
- INPUT answer
- Condition
- answer == "drama"
- True
- output
- OUTPUT
Matched message
- False
- output
- OUTPUT
Card message
- After
- output
- OUTPUT
Question finished
Compare two integers, including equal values
Original Paxa larger-value program
first = int(input())
second = int(input())
if first >= second:
print("Larger value:", first)
else:
print("Larger value:", second)Predict the selected value and branch
| First | Second | Condition | Printed value |
|---|---|---|---|
| 6 | 9 | {'clue': 'True or False', 'prompt': 'Condition for first 6, second 9', 'answers': ['False']} | {'clue': 'Numeric value', 'prompt': 'Larger output for 6 and 9', 'answers': ['9']} |
| 4 | 4 | {'clue': 'True or False', 'prompt': 'Condition for first 4, second 4', 'answers': ['True']} | {'clue': 'Numeric value', 'prompt': 'Larger output for 4 and 4', 'answers': ['4']} |
| 12 | -3 | {'clue': 'True or False', 'prompt': 'Condition for first 12, second -3', 'answers': ['True']} | {'clue': 'Numeric value', 'prompt': 'Larger output for 12 and -3', 'answers': ['12']} |
| -7 | 0 | {'clue': 'True or False', 'prompt': 'Condition for first -7, second 0', 'answers': ['False']} | {'clue': 'Numeric value', 'prompt': 'Larger output for -7 and 0', 'answers': ['0']} |
Modify the comparison and add a shared total
Original Paxa smaller-value and sum version
first = int(input())
second = int(input())
if first <= second:
print("Smaller value:", first)
else:
print("Smaller value:", second)
print("Sum:", first + second)Plan a fictional age-record comparison
| Case | What to test |
|---|---|
| First older | Ari 16; Noor 14 -> select Ari. |
| Second older | Ari 13; Noor 15 -> select Noor. |
| Equal ages | Ari 14; Noor 14 -> select first alias Ari. |
| Record of work | Plan, full code, predicted/observed output or Pending. |
Prepare complete program and test evidence
For a text quiz, test the exact answer, a different answer and different capitalisation. For two integers, test first greater, second greater, equality and negative values. For the fictional age records, test both orders and equality. Mark individual review or name actual partner involvement honestly.
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: How many condition expressions does a basic if/else need? one
- Question 2: Which header is valid for the alternative branch? else:
Worksheet 2
- Question 3: Which condition chooses the True branch? answer == "drama"
- Question 4: How many leading spaces indent each branch print statement? 4
- Question 5: What prints after either branch if execution reaches it? Question finished
Worksheet 3
- Question 6: Branch message for drama Matched
- Question 7: Branch message for Drama Card
- Question 8: Branch message for music Card
- Question 9: Branch message for DRAMA Card
- Question 10: Including the question and final message, how many output lines print for input music? 3
Worksheet 4
- Question 11: Which line belongs to the False block? print("The club card says drama")
- Question 12: Which pair of changes keeps a chess version consistent? compare with chess and reveal chess in the fallback
- Question 13: What would indenting Question finished inside else do? make it print only for a nonmatch
Worksheet 5
This page introduces the activity. There are no marked responses on this sheet.
Worksheet 6
- Question 14: Write the comparison operator in this program. >=
- Question 15: For equal inputs, which branch executes? the if branch
- Question 16: Why is a negative input valid here? int can read signed integer text
Worksheet 7
- Question 17: Condition for first 6, second 9 False
- Question 18: Larger output for 6 and 9 9
- Question 19: Condition for first 4, second 4 True
- Question 20: Larger output for 4 and 4 4
- Question 21: Condition for first 12, second -3 True
- Question 22: Larger output for 12 and -3 12
- Question 23: Condition for first -7, second 0 False
- Question 24: Larger output for -7 and 0 0
Worksheet 8
- Question 25: For inputs 6 and 9, what smaller value is printed? 6
- Question 26: For inputs 6 and 9, what sum is printed? 15
- Question 27: For inputs -7 and 0, what smaller value is printed? -7
- Question 28: For inputs -7 and 0, what sum is printed? -7
Worksheet 9
- Question 29: Which comparison selects the first record at equality? first_age >= second_age
- Question 30: What may you conclude when the ages are equal? the selected first alias follows the tie policy
Worksheet 10
- Question 31: What evidence tests both numeric branches plus equality? 6/9, 9/6 and 4/4
- Question 32: Which change requires the branch messages to be checked again? changing the quiz answer
Worksheet 11
- Question 33: Modify the supplied club-card program to use chess and replace both branch messages. Then create a separate original two-response quiz about an invented character or a fictional preference. State the exact accepted answer. Use aligned if/else headers, four-space action blocks and a shared final message. Identify the condition, comparison operator, True/False actions and outside actions. Test exact, incorrect and differently capitalised answers for both programs. Record predictions, actual output or Pending and a correction or evidence that no correction was needed. Cite full saved source and test records if used. Modified quiz consistently compares chess and reveals chess if needed, both messages changed. New original quiz has explicit correct answer and meaningful two responses using lowercase if/else, colons, ==, consistent four spaces and shared final statement outside. Three test categories for both versions, exact branch/outside traces and code evidence. Mark conditions/operator/block/outside. No automatic text normalisation assumed; if intentionally added, document changed policy and test accordingly. Predictions versus actual/Pending distinct. Reflection grounded in evidence, honest peer or individual mode, no numerical marks. Grown-up review; personal evidence is required.
Worksheet 12
- Question 34: Save or write the smaller-value program with an outside sum from page 8, then make the fictional alias-and-age selector described on page 9. Show your plan and full code, or cite actual saved files. For the integer program test first smaller, second smaller, equal and negative inputs. For ages test first older, second older and equal; apply the specified first-alias tie policy without calling equal ages strictly older. Record predicted and actual output or Pending. Explain one comparison choice, the shared sum statement and any correction with a retest. Smaller-value code if first = second_age else second; alias/age association preserved; tie rule explicit in stated specification and result explanation, no strict-older assertion at equality. Both orders/equality tested. Complete code/file evidence, predictions/actual/Pending and correction/retest honest. Accept logically equivalent two-way solution. No collected real personal data or invented learner activity. Grown-up review; personal evidence is required.
Curriculum & workbook reference
- Cambridge Lower Secondary Computing Learner’s Book 8 — pages 78–84
- PaxaKids Grade 8 Computing Lesson 1.20: Two-way IF ELSE programs — pages 1–12
Computing for your homeschool day
Explore Two-way IF ELSE programs 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.
