GRADE 8 · COMPUTING · UNIT 1 · LESSON 1.25

Computational thinking and programming

Trace, debug and reflect

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

Topic 1.25 · Trace, debug and reflect14 fillable worksheet pagesRead at your own pace

LET’S TRACE, REASON AND TEST

Trace, debug and reflect

Debugging compares intended behaviour with actual or traced behaviour. Locate the first meaningful mismatch, change the cause and retest the affected cases. Do not claim a program is correct merely because one test passes.

Today’s two goals
  • Explain outputs and repair keyword, equality, colon, indentation, ELSE placement and Boolean-expression mistakes.
  • Explain my method and support it with a labelled trace, example or test record.
Original PaxaKids illustration for Trace, debug and reflect. 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

A rule meant to include 10 uses x > 10 and rejects 10. An independent expected result shows the boundary mistake; change the comparison to >= and retest values below, at and above 10.

Try before your workbook

Which three nearby integer inputs help retest the corrected threshold of at least 10?

Explore the clues

Tap one card to find out more.

Understand the idea

Debugging compares intended behaviour with actual or traced behaviour. Locate the first meaningful mismatch, change the cause and retest the affected cases. Do not claim a program is correct merely because one test passes.

Concept to practise: Trace, debug and reflect.

Work through an example

A rule meant to include 10 uses x > 10 and rejects 10. An independent expected result shows the boundary mistake; change the comparison to >= and retest values below, at and above 10.

Try before your workbook

Which three nearby integer inputs help retest the corrected threshold of at least 10?

Check my readiness thinking

Use 9, 10 and 11, expecting reject, accept and accept. Record actual results separately so a prediction is not mistaken for execution.

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.

Trace, repair and explain your evidence

Debugging means finding and correcting errors. A syntax or indentation error can stop a program before it runs. A logic error may let it run while producing the wrong result.

Start from the intended rule, predict a useful test, examine the code and compare actual behaviour if you execute it. Record the change and retest. This review uses original examples and completes the selection-topic checklist.

Review blocks and a simple equality boundary

Read the original code. The value equals the comparison boundary, so the strict less-than test is false. Only one branch message prints.
Original Paxa review trace
value = 8
if value < 8:
    print("Open")
else:
    print("Closed")

Review ELIF execution and unchanged values

The first true condition selects its action. An elif condition is evaluated only if all earlier conditions in that chain were false. If no branch matches and there is no else, an existing variable can keep its earlier value.
Original Paxa assignment trace
first = "go"
second = "stop"
total = 7
if first == "stop":
    total = 11
elif second == "stop":
    total = 23
print(total)

Repair keyword, comparison and header punctuation

These are four separate incorrect headers. Each is intended to be followed by a four-space print("Ready") action. A, C and D mean at least 4; B means exactly 4. Write the complete corrected header for each.
Incorrect headers A and B
A  IF parcels >= 4:
B  if parcels = 4:
Incorrect headers C and D
C  if parcels >= 4
D  if parcels => 4:

Repair indentation rather than only appearance

These independent excerpts assume count already stores an integer. Both should print Ready at 4 or above, otherwise Wait. Version A has a missing action indent. Version B has a misplaced else and overindented False action.
A: missing action indent
if count >= 4:
print("Ready")
else:
    print("Wait")
B: wrong else alignment
if count >= 4:
    print("Ready")
    else:
        print("Wait")

Use elif and put else last

Both excerpts should output Small below 4, Medium from 4 through 7 and Large at 8 or above. They are intentionally broken. Fix structure while preserving each condition and its matching output.
A: wrong alternative keyword
if count < 4:
    print("Small")
else if count < 8:
    print("Medium")
else:
    print("Large")
B: fallback before a test
if count < 4:
    print("Small")
else:
    print("Large")
elif count < 8:
    print("Medium")

Give one fallback its colon and block

These independent excerpts assume a valid integer count. Both intend Small below 4 and Large otherwise. A is missing punctuation. B contains a second fallback that the stated rule does not need.
A: incomplete else header
if count < 4:
    print("Small")
else
    print("Large")
B: duplicate fallback
if count < 4:
    print("Small")
else:
    print("Large")
else:
    print("Other")

Repair complete Boolean expressions

Each labelled line is an incorrect header with a valid indented action assumed below it. A should require count above 0 and below 8. B means count above 0 and limit below 8. C reverses count > 0. D accepts kind art or science.
Incorrect headers A and B
A  if count > 0 and:
B  if count > 0 AND limit < 8:
Incorrect headers C and D
C  if count > 0 not:
D  if kind == "art" or "science":

Distinguish valid syntax from correct logic

The policy says select Long activity from 45 minutes, Short activity from 20 through 44 and More time needed below 20. The following program runs but tests a broad condition too early.
Intentional wrong-order logic example
minutes = int(input())
if minutes >= 20:
    print("Short activity")
elif minutes >= 45:
    print("Long activity")
else:
    print("More time needed")

Plan a complete integrated repair

The rule for valid nonnegative integer count is: Pack when count is at least 6 and kind is exact art; otherwise Shared when count is at least 3; otherwise Wait. Print Checked after either decision outcome. This complete original program is intentionally broken.
Original Paxa repair task; intentional errors
count = int(input())
kind = input()
IF count = 6 AND kind == "art"
print("Pack")
else if count >= 3:
    print("Shared")
else:
    print("Wait")
print("Checked")

Predict the repaired program before running it

Use the page 10 specification. Complete the first output line for each case. Checked should be the second output line in every valid case. These predictions belong to the corrected policy, not the broken listing.
Predict the repaired program before running it — original model
CountKindFirst output
6art{'clue': 'Exact output', 'prompt': 'Corrected integrated output for 6/art', 'answers': ['Pack']}
5art{'clue': 'Exact output', 'prompt': 'Corrected integrated output for 5/art', 'answers': ['Shared']}
6science{'clue': 'Exact output', 'prompt': 'Corrected integrated output for 6/science', 'answers': ['Shared']}
2art{'clue': 'Exact output', 'prompt': 'Corrected integrated output for 2/art', 'answers': ['Wait']}
6ART{'clue': 'Exact output', 'prompt': 'Corrected integrated output for 6/ART', 'answers': ['Shared']}

Review five selection skills using real evidence

Use these five original skill statements in the same order as the source checklist. Give Ready, Practising or Pending and cite an exact trace, repaired line, test or created program. A claim without evidence is not a completed skill record.
Review five selection skills using real evidence — original model
IDSkill
1Trace a Python if/elif/else chain.
2Write a Python if/elif/else chain.
3Write a chain with more than one elif.
4Trace selection using and, or and not.
5Write selection using and, or and not.

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.

Trace, debug and reflect14 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.2 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 starts a conditional statement? if
  2. Question 2: What proves that a runnable program follows its policy? appropriate tests with outputs compared to the stated rule

Worksheet 2

  1. Question 3: How does Python identify the statements inside a block? consistent indentation
  2. Question 4: What exact output does this program print? Closed
  3. Question 5: What is the largest number of else blocks in one chain? 1

Worksheet 3

  1. Question 6: What number prints for the code exactly as shown? 23
  2. Question 7: If both first and second are go instead, what number prints? 7
  3. Question 8: If first is stop, is the elif condition evaluated? no, the first branch was selected

Worksheet 4

  1. Question 9: Correct A. if parcels >= 4:
  2. Question 10: Correct B. if parcels == 4:
  3. Question 11: Correct C. if parcels >= 4:
  4. Question 12: Correct D. if parcels >= 4:

Worksheet 5

  1. Question 13: Which change fixes A? indent print("Ready") by four spaces
  2. Question 14: Which change fixes B? align else with if and indent its print by four spaces

Worksheet 6

  1. Question 15: Which keyword replaces else if in A? elif
  2. Question 16: Which structural change fixes B? move the elif condition and Medium action before else

Worksheet 7

  1. Question 17: Write the corrected else header for A. else:
  2. Question 18: Which repair makes B match its stated two-outcome rule? remove the second else and its Other action

Worksheet 8

  1. Question 19: Write the corrected A header. if count > 0 and count < 8:
  2. Question 20: Write the lowercase Boolean operator required in B. and
  3. Question 21: Write the corrected C header, using not and grouping parentheses. if not (count > 0):
  4. Question 22: Write the complete corrected D header. if kind == "art" or kind == "science":

Worksheet 9

  1. Question 23: What does this version actually print for input 45? Short activity
  2. Question 24: Which correction implements the policy? test >= 45 with Long activity before >= 20 with Short activity

Worksheet 10

  1. Question 25: Which first header implements the stated rule? if count >= 6 and kind == "art":
  2. Question 26: Which line must remain outside the chain? print("Checked")

Worksheet 11

  1. Question 27: Corrected integrated output for 6/art Pack
  2. Question 28: Corrected integrated output for 5/art Shared
  3. Question 29: Corrected integrated output for 6/science Shared
  4. Question 30: Corrected integrated output for 2/art Wait
  5. Question 31: Corrected integrated output for 6/ART Shared

Worksheet 12

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

Worksheet 13

  1. Question 32: Create an original program that reads a fictional year-group integer. Use this complete policy: 7 prints Explore basics; 8 prints Develop ideas; 9 prints Extend projects; every other integer prints Ask adviser. Use if, at least two elif alternatives and one final else with four-space actions. Test 7, 8, 9, 6 and 11, recording predictions and actual output or Pending. Cite full code and tests if saved. Then give Ready, Practising or Pending plus exact evidence for each of the five page 12 skills, including Boolean work from this or earlier selection lessons. Identify one next step. Year int input, exact if year == 7 -> Explore basics; elif ==8 -> Develop ideas; elif ==9 -> Extend projects; else Ask adviser. Valid domain any integer, malformed-text handling not assumed. Five required cases outputs correspond, full code/records, predictions/actual or Pending, at least two elif and single final else aligned with four-space actions. All five source skill meanings preserved in order with nonnumeric status and precise actual evidence; Boolean-writing/tracing may cite lessons 1.23/1.24 or repaired examples. No unsupported confidence claim, numeric marks or fabricated execution. Grown-up review; personal evidence is required.

Worksheet 14

  1. Question 33: Repair the complete page 10 program to match its stated policy. Keep the full corrected source or cite its saved file. Explain each change: lowercase if, inclusive comparison, lowercase and, missing colon, first-action indentation and elif spelling. Use all five page 11 cases and show both expected output lines. Run the same inputs if possible, record actual output or Pending, and retest any further change. Explain why count 6 with science selects Shared and why Checked must remain unindented. Describe individual work or actual help received honestly. Correct full program matches supplied specification: count int, kind string; if count >= 6 and kind == "art": indented Pack; elif count >=3: Shared; else Wait; Checked outside. Explain six named changes, including replacing assignment-like = by intended >= rather than merely == because policy is inclusive. Tests 6/art Pack,5/art Shared,6/science Shared,2/art Wait,6/ART Shared; every valid case followed by Checked. Exact case, first-match reasoning, complete source and prediction/actual/Pending records, correction/retest evidence and actual help documented. No unperformed GUI activity or numeric marks. Grown-up review; personal evidence is required.
Back to my workbook ↑

Curriculum & workbook reference

Computing for your homeschool day

Explore Trace, debug and reflect 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.