GRADE 8 · COMPUTING · UNIT 1 · LESSON 1.21

Computational thinking and programming

Ordered ELIF choices

Read a little. Try the workbook. Check your answers. Choose one section below to get started.

Topic 1.21 · Ordered ELIF choices14 fillable worksheet pagesRead at your own pace

LET’S TRACE, REASON AND TEST

Ordered ELIF choices

Python elif continues an ordered choice chain. Put more restrictive conditions first when ranges overlap, and define the fallback. An earlier match prevents later elif branches from running.

Today’s two goals
  • Construct multiple alternatives, add a fallback, arrange thresholds in a meaningful order and compare representations.
  • Explain my method and support it with a labelled trace, example or test record.
Original PaxaKids illustration for Ordered ELIF choices. Use the supplied program and data models for precise workbook facts.
An original PaxaKids workbook scene. Use the supplied programs and data for precise workbook facts.

Work through an example

With if points >= 30 followed by elif points >= 15, points 35 enters the first branch. Reversing those conditions would let the broader threshold catch 35 first.

Try before your workbook

For those original thresholds, which branch handles points 20?

Explore the clues

Tap one card to find out more.

Understand the idea

Python elif continues an ordered choice chain. Put more restrictive conditions first when ranges overlap, and define the fallback. An earlier match prevents later elif branches from running.

Concept to practise: Ordered ELIF choices.

Work through an example

With if points >= 30 followed by elif points >= 15, points 35 enters the first branch. Reversing those conditions would let the broader threshold catch 35 first.

Try before your workbook

For those original thresholds, which branch handles points 20?

Check my readiness thinking

The elif points >= 15 branch, because the >= 30 condition is false. Check the order as well as the comparison signs.

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.

Use several ordered alternatives

An art-material selector can choose one tray from several possibilities. Python begins with if, adds alternatives with elif and can finish with one optional else.

Conditions are checked in written order until one is true. That branch runs; later alternatives are skipped. If none is true, the fallback else runs when supplied.

Read several exact-match alternatives

This original tray policy maps exact red to Tray A, blue to Tray B and green to Tray C. Any other string asks for a tray. All valid text inputs reach the final message.
Original Paxa tray selector
colour = input()
if colour == "red":
    print("Tray A")
elif colour == "blue":
    print("Tray B")
elif colour == "green":
    print("Tray C")
else:
    print("Ask for a tray")
print("Selection complete")

Compare a chain with and without a fallback

These excerpts use the same first two exact colour tests. A missing fallback is legal, but unmatched text produces no branch message. The shared final print is still reached. Use lowercase red or blue for a match.
A: no fallback
colour = input()
if colour == "red":
    print("Tray A")
elif colour == "blue":
    print("Tray B")
print("Selection complete")
B: with fallback
colour = input()
if colour == "red":
    print("Tray A")
elif colour == "blue":
    print("Tray B")
else:
    print("Ask for a tray")
print("Selection complete")

Trace matching, unmatched and capitalised text

Use the full page 2 program. Write only the selected branch output, before Selection complete. The accepted strings are exact and case-sensitive.
Trace matching, unmatched and capitalised text — original model
Entered stringBranch output
red{'clue': 'Exact branch text', 'prompt': 'Tray selection for red', 'answers': ['Tray A']}
blue{'clue': 'Exact branch text', 'prompt': 'Tray selection for blue', 'answers': ['Tray B']}
green{'clue': 'Exact branch text', 'prompt': 'Tray selection for green', 'answers': ['Tray C']}
gold{'clue': 'Exact branch text', 'prompt': 'Tray selection for gold', 'answers': ['Ask for a tray']}
Red{'clue': 'Exact branch text', 'prompt': 'Tray selection for Red', 'answers': ['Ask for a tray']}

Arrange original lines and restore indentation

Two fictional teams count collected markers. Read the left name, right name, left count and right count in that order. Report Draw at equality; otherwise report the team with the larger count. The labels A–J are line-card IDs, not Python code. Every quote is already closed.
Shuffled line cards; branch actions currently unindented
A  print(right, "leads")
B  left_count = int(input())
C  if left_count == right_count:
D  left = input()
E  print(left, "leads")
F  right_count = int(input())
G  else:
H  right = input()
I  print("Draw")
J  elif left_count > right_count:

Test equality and both leading teams

Use the reconstructed line-card program. Fictional team names are Lark and Wren. Counts are task data, not learner marks. Enter both names before the two integer counts.
Test equality and both leading teams — original model
Lark countWren countExact output
55{'clue': 'Output text', 'prompt': 'Team result for 5 and 5', 'answers': ['Draw']}
83{'clue': 'Output text', 'prompt': 'Team result for 8 and 3', 'answers': ['Lark leads']}
27{'clue': 'Output text', 'prompt': 'Team result for 2 and 7', 'answers': ['Wren leads']}

Put overlapping thresholds in useful order

For this art-only workshop version, valid minutes are integers from 0 to 120. At least 45 minutes selects Paper sculpture. Otherwise at least 20 selects Pattern tiles. Less than 20 selects Choose a longer time. These are original C04 workshop policy thresholds in a simplified single-interest version.
Specific higher threshold first
minutes = int(input())
if minutes >= 45:
    print("Paper sculpture")
elif minutes >= 20:
    print("Pattern tiles")
else:
    print("Choose a longer time")

Check both threshold boundaries

Use page 7. Complete the selected activity for each valid input. Include the exact boundary and a nearby value on either side of the rule change.
Check both threshold boundaries — original model
MinutesSelected activity
19{'clue': 'Exact message', 'prompt': 'Workshop for 19 minutes', 'answers': ['Choose a longer time']}
20{'clue': 'Exact message', 'prompt': 'Workshop for 20 minutes', 'answers': ['Pattern tiles']}
44{'clue': 'Exact message', 'prompt': 'Workshop for 44 minutes', 'answers': ['Pattern tiles']}
45{'clue': 'Exact message', 'prompt': 'Workshop for 45 minutes', 'answers': ['Paper sculpture']}
46{'clue': 'Exact message', 'prompt': 'Workshop for 46 minutes', 'answers': ['Paper sculpture']}

Diagnose a runnable ordering mistake

This version has valid Python syntax but does not follow the stated workshop policy. It checks the broad lower threshold first. Predict what it actually prints rather than what the policy intended.
Intentional wrong-order example
minutes = int(input())
if minutes >= 20:
    print("Pattern tiles")
elif minutes >= 45:
    print("Paper sculpture")
else:
    print("Choose a longer time")

Match pseudocode and Python feature by feature

Both representations below implement the same art workshop algorithm. Pseudocode uses THEN and ENDIF; Python replaces them with colons and block indentation.
Pseudocode
INPUT minutes
IF minutes >= 45 THEN
    OUTPUT "Paper sculpture"
ELSEIF minutes >= 20 THEN
    OUTPUT "Pattern tiles"
ELSE
    OUTPUT "Choose a longer time"
ENDIF
Python 3
minutes = int(input())
if minutes >= 45:
    print("Paper sculpture")
elif minutes >= 20:
    print("Pattern tiles")
else:
    print("Choose a longer time")

Match the same algorithm to a flowchart

Start with an input value, then follow the labelled results. A false first decision leads to the next decision. All selected outputs lead to Stop. The flowchart uses exactly the same policy as pages 7 and 10.
Match the same algorithm to a flowchart — original labelled workbook model. The following text version gives its labels and values.
Match the same algorithm to a flowchart · original PaxaKids model.
Read this model’s labels and values
Before
    1. input
    2. INPUT minutes
Routes
    1. minutes >= 45
    2. output
    3. Paper sculpture
    1. minutes >= 20
    2. output
    3. Pattern tiles
Otherwise
Choose a
longer time

Prepare practical tests and a linked poster

For the line-card task, preserve the input order and restore four-space action blocks. For the tray selector, check matching colours, unmatched gold and capitalised Red. Use Python 3 if available, compare predictions with actual output and retest corrections; otherwise mark execution Pending.

For the poster, show one algorithm in three forms and link matching conditions and outputs. Use the supplied poster brief and attach a larger sheet or file if needed. Describe an actual partner review only if one occurred.

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.

Paxa the Fox

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
  1. Lesson 1.1: Recall algorithms and representations
  2. Lesson 1.2: Purpose and conventions of pseudocode
  3. Lesson 1.3: Input, output and strings
  4. Lesson 1.4: Identifiers and assignment
  5. Lesson 1.5: Arithmetic and translation
  6. Lesson 1.6: Trace and review a sequence
  7. Lesson 1.7: Conditions and two-way flow
  8. Lesson 1.8: IF THEN and indentation
  9. Lesson 1.9: IF THEN ELSE and decision diagrams
  10. Lesson 1.10: Ordered ELSEIF and fallback ELSE
  11. Lesson 1.11: Match flowchart and pseudocode branches
  12. Lesson 1.12: AND, OR and NOT
  13. Lesson 1.13: Grouping, precedence and review
  14. Lesson 1.14: Why software searches
  15. Lesson 1.15: A successful linear search
  16. Lesson 1.16: An unsuccessful search and termination
  17. Lesson 1.17: Practise and communicate the search
  18. Lesson 1.18: Translate conditions into Python
  19. Lesson 1.19: One-branch IF programs
  20. Lesson 1.20: Two-way IF ELSE programs
  21. Lesson 1.21: Ordered ELIF choices
  22. Lesson 1.22: Ranges and independent decisions
  23. Lesson 1.23: Boolean operators in Python
  24. Lesson 1.24: Design and test recommendations
  25. Lesson 1.25: Trace, debug and reflect
  26. Lesson 1.26: Choose data types and recognise Boolean literals
  27. Lesson 1.27: Set and use Boolean flags
  28. Lesson 1.28: Explain and identify constants
  29. Lesson 1.29: Express constants in three algorithm forms
  30. Lesson 1.30: Use a fixed factor in a calculation
  31. Lesson 1.31: Cast to Boolean and validate an empty response
  32. Lesson 1.32: Recall calls and trace return values
  33. Lesson 1.33: Supply parameters and reuse library code
  34. Lesson 1.34: Choose and import libraries responsibly
  35. Lesson 1.35: Round with floor and ceiling
  36. Lesson 1.36: Use pi and investigate another mathematical feature
  37. Lesson 1.37: Generate random choices within bounds
  38. Lesson 1.38: Investigate random real values and review library use
  39. Lesson 1.39: Retrieve test tables and predict selection outcomes
  40. Lesson 1.40: Decompose everyday problems
  41. Lesson 1.41: Decompose programs and organise shared work
  42. Lesson 1.42: Develop through repeated build/test cycles
  43. Lesson 1.43: Predict and verify algorithm outcomes
  44. Lesson 1.44: Choose representative and boundary tests
  45. Lesson 1.45: Build, execute and review a test plan
  46. Lesson 1.46: Recall physical inputs and compare transmission media
  47. Lesson 1.47: Configure a radio group and agree a message scheme
  48. Lesson 1.48: Send and receive numbers and strings
  49. Lesson 1.49: Trace numeric message sequences
  50. Lesson 1.50: Transmit text and use received data in conditions
  51. Lesson 1.51: Diagnose and extend a message protocol
  52. Lesson 1.52: Review communication and evidence of testing
  53. Lesson 1.53: Project 1: Adventure story
  54. Lesson 1.54: Project 2: Fire, Water, Earth
  55. 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.

Ordered ELIF choices14 student pages · original artwork

Opening your PDF…

Swipe sideways across the worksheet on a small screen, or use “Answer list” for larger controls.

TAKE YOUR PRACTICE OFFLINE

3. Download the student worksheet

All 14 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

Download worksheet PDF ↓

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 14 worksheets

Worksheet 1

  1. Question 1: Which Python keyword adds another tested alternative? elif
  2. Question 2: What happens after the first true condition in one chain? its block runs and later alternatives are skipped

Worksheet 2

  1. Question 3: Where must the fallback else appear? after all elif alternatives in its chain
  2. Question 4: Which headers must line up here? if, elif and else

Worksheet 3

  1. Question 5: What does version A print for gold? Selection complete only
  2. Question 6: What does version B print for gold? Ask for a tray then Selection complete

Worksheet 4

  1. Question 7: Tray selection for red Tray A
  2. Question 8: Tray selection for blue Tray B
  3. Question 9: Tray selection for green Tray C
  4. Question 10: Tray selection for gold Ask for a tray
  5. Question 11: Tray selection for Red Ask for a tray

Worksheet 5

  1. Question 12: Write the card IDs in program order, separated by commas. D,H,B,F,C,I,J,E,G,A
  2. Question 13: Which three action-card IDs need four leading spaces? Write alphabetically. A,E,I

Worksheet 6

  1. Question 14: Team result for 5 and 5 Draw
  2. Question 15: Team result for 8 and 3 Lark leads
  3. Question 16: Team result for 2 and 7 Wren leads
  4. Question 17: After equality has been ruled out, what does the final else cover? the right count is greater

Worksheet 7

  1. Question 18: For 50 minutes, how many workshop branch messages print? one
  2. Question 19: Why does >= 45 come before >= 20 here? a long session satisfies both comparisons but needs the longer activity

Worksheet 8

  1. Question 20: Workshop for 19 minutes Choose a longer time
  2. Question 21: Workshop for 20 minutes Pattern tiles
  3. Question 22: Workshop for 44 minutes Pattern tiles
  4. Question 23: Workshop for 45 minutes Paper sculpture
  5. Question 24: Workshop for 46 minutes Paper sculpture

Worksheet 9

  1. Question 25: What activity does this wrong-order version print for 50? Pattern tiles
  2. Question 26: Why can its Paper sculpture branch never be selected for valid minutes? every value at least 45 already matches the earlier >= 20 test
  3. Question 27: Which repair preserves the intended activity mapping? place >= 45 and its action before >= 20 and its action

Worksheet 10

  1. Question 28: Which Python feature matches pseudocode ELSEIF? elif with a condition and colon
  2. Question 29: Which Python feature shows where a branch block ends? a return to the earlier indentation level

Worksheet 11

This page introduces the activity. There are no marked responses on this sheet.

Worksheet 12

  1. Question 30: Which test proves the fallback is handled in the tray program? gold
  2. Question 31: Which poster is consistent? all three forms choose Paper sculpture at exactly 45

Worksheet 13

  1. Question 32: Reconstruct the page 5 team program with the supplied input order and four-space action blocks. Save full code or write it clearly. Predict and test equality, left-leading and right-leading cases from page 6. Then enter or open the complete tray selector and test all five page 4 strings. Annotate if/elif/else, the comparisons, branch actions and shared output where present. Compare predictions with actual output or mark execution Pending. Record a correction and retest if needed. Use actual peer review if available; otherwise label individual review. Cite the full code and test-record files. Team order D,H,B,F,C,I,J,E,G,A, indent I/E/A four spaces; names read then counts, equality Draw, otherwise left lead then right lead. All quotes complete; do not reproduce source missing closing quote. Team tests 5/5 Draw,8/3 Lark leads,2/7 Wren leads with names Lark/Wren. Tray red/A,blue/B,green/C,gold/Ask,Red/Ask; Selection complete follows every branch. Full source and exact prediction/actual or Pending evidence, syntax and annotation correct; correction/retest if needed and honest individual/partner stage. No invented GUI or numeric marks. Grown-up review; personal evidence is required.

Worksheet 14

  1. Question 33: Make a Flowchart to Pseudocode to Python poster for the workshop rule on pages 7–11. Show the same input, ordered thresholds, three outputs and stopping paths in all forms. Include IF/THEN, ELSEIF, ELSE and ENDIF in pseudocode; if, elif, else, colons and four-space blocks in Python; and labelled True/False arrows in the flowchart. Link corresponding decisions and actions. Use this space to plan or cite a larger attached poster. Check all five page 8 inputs across all representations and record any correction. Same valid integer minutes domain 0–120, >=45 Paper sculpture, otherwise >=20 Pattern tiles, otherwise Choose a longer time. Flowchart input/parallelogram, two decisions/diamonds ordered 45 then 20 via false path, labelled True/False, one matching output, joined Stop; Python/pseudocode semantically identical with correct language syntax/indentation. Corresponding features linked, no backwards/rerun path. Five cases 19/20/44/45/46 match all forms. Original poster or actual attached file and concrete evidence; no invented production or peer review. No numerical marks. Grown-up review; personal evidence is required.
Back to my workbook ↑

Curriculum & workbook reference

Computing for your homeschool day

Explore Ordered ELIF choices 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.