GRADE 7 · COMPUTING · UNIT 6 · LESSON 6.6

Sequencing and pattern recognition: Getting the message across

Identifying errors and debugging

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

8 fillable worksheet pagesRead at your own pace

LET’S TRACE, REASON AND TEST

Identifying errors and debugging

Debugging locates and corrects errors, then retests against the requirements. A program can fail to parse, fail while running or run with the wrong output sequence. Fixing a syntax error does not prove the whole program is correct.

Today’s two goals
  • Use sequence patterns and a flowchart to locate an incorrect program action.
  • Distinguish syntax mistakes from a program that runs but produces the wrong sequence.
Original PaxaKids illustration for Identifying errors and debugging. Precise program text and data are supplied in the workbook models.
An original PaxaKids workbook scene. Use the supplied programs and data for precise workbook facts.

Explore the clues

Tap one card to find out more.

Understand the idea

Debugging locates and corrects errors, then retests against the requirements. A program can fail to parse, fail while running or run with the wrong output sequence. Fixing a syntax error does not prove the whole program is correct.

Concept to practise: Identifying errors and debugging.

Work through an example

The supplied faulty sound-triggered starter includes a syntax problem, an incorrect image name and an order error. Compare each repair with the intended flowchart, save a new revision and test the inactive and triggered cases.

Try before your workbook

If a repaired program now starts, what else must you check before claiming that its visual alarm meets the plan?

Check my readiness thinking

Check trigger behaviour, image identity and order, waits, clearing and return to monitoring. The built-in microphone practical requires suitable micro:bit V2 hardware. Keep actual tests separate from predicted traces or controlled test stubs.

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.

Find, explain, repair and retest

Debugging means locating and correcting errors. A program may fail to parse, fail while running, or run successfully while producing the wrong sequence. Each needs evidence and a suitable repair.

Testing compares behaviour with requirements. A correction needs a retest: fixing one line does not establish that every other requirement works.

Use a sequence pattern to locate a mismatch

Use a sequence pattern to locate a mismatch — original model
PositionRequired outputTraced faulty output
1HEARTHEART
2DIAMONDTRIANGLE
3TRIANGLEDIAMOND

Trace the required sound-response routine

The next practical uses a micro:bit V2 microphone. A recorded loud event should call correct, which performs this sequence and then returns to monitoring.
  1. correct
  2. Play ENTERTAINER tune
  3. Wait 500 ms
  4. Display YES tick
  5. Wait 2000 ms
  6. Clear display
  7. Return

Keep the inactive path clear

This main chart waits for a recorded loud event, rather than measuring a fixed number of decibels. Without one, clear the display. After a response, monitor again.

    Decision: Loud event?

    True branch
    1. correct
    False branch
    1. Clear display

    Inspect the original faulty starter

    Open DebugProgram_Paxa.py. The intended routine is on page 3. This original file contains a syntax error, an incorrect image name and an output-order error. Save corrections under a new revision name.
    Original program model
    from microbit import *
    import music
    
    def correct():
        display.show(Image.Yes)
        sleep(2000)
        music.play(music.ENTERTAINER)
        sleep(500)
        display.clear()
        microphone.was_event(SoundEvent.LOUD)
    
    display.clear()
    while True:
        if microphone.was_event(SoundEvent.LOUD)
            correct()
        else:
            display.clear()
        sleep(30)

    Use a focused debugging checklist

    Use a focused debugging checklist — original model
    AreaWhat to inspect
    ImportsDevice names imported; music module imported.
    Brackets and quotesCalls close correctly; text literals have matching quotes.
    Colon and indentationif, while and def use a colon and an indented body.
    Exact namesImage.YES uses uppercase YES; spelling and case matter.
    Order and timingCompare every action and delay with the flowchart.
    Retest evidenceUse the saved revision; check active and inactive paths.

    Practice files for this lesson

    Save a copy of these original PaxaKids learner files before editing in suitable software. Some code and datasets deliberately need completion or repair. Downloading a file does not run it. Use invented data; record actual tests separately from predictions. Native software practice files are not print-optimised; use the student PDF for printing.

    Paxa the Fox

    Try one step with Paxa!

    Use supplied fictional records. Do not disclose personal details, upload private photos or bypass browser warnings to complete an activity. Save personal responses before leaving.

    Our Unit 6 learning path
    1. Lesson 6.1: Prototyping
    2. Lesson 6.2: Pattern recognition
    3. Lesson 6.3: Patterns between text-based programming languages
    4. Lesson 6.4: Boolean selection and sub-routines
    5. Lesson 6.5: Project plans and test plans
    6. Lesson 6.6: Identifying errors and debugging
    7. Lesson 6.7: Sequences and lights
    8. Lesson 6.8: Creating a moving sequence of lights
    9. Lesson 6.9: Extending a light sequence
    10. Lesson 6.10: Light brightness
    11. Lesson 6.11: Loading-screen and name-sequence extensions
    12. Lesson 6.12: Final project: Sound-triggered visual alarm
    13. Lesson 6.13: Evaluation
    14. Lesson 6.14: What can you do?
    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 the 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.

    Identifying errors and debugging8 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 8 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 8 worksheets

    Worksheet 1

    1. Question 1: Which can be a logic error in a program that runs? two valid output actions in the wrong order
    2. Question 2: What should follow a repair? retest against the requirements

    Worksheet 2

    1. Question 3: At which position does the first mismatch occur? 2
    2. Question 4: What repair matches the required sequence? exchange the second and third image actions

    Worksheet 3

    1. Question 5: When does the half-second pause begin? after the tune call completes

    Worksheet 4

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

    Worksheet 5

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

    Worksheet 6

    1. Question 6: After the missing colon is repaired, Image.Yes is best described as what? a wrong attribute name that can fail when executed

    Worksheet 7

    1. Question 7: Repair DebugProgram_Paxa.py and explain each error and correction. Use the intended routine and main chart to justify the order, waits and inactive behaviour. Give the saved revision. Explain to a partner why debugging and testing matter, what could happen if an untested program were released, and examples of MicroPython mistakes. Record the discussion, or mark it Pending. Add the missing colon after the loud-event condition. Correct Image.Yes to Image.YES. Reorder the routine to play ENTERTAINER, sleep(500), show YES, sleep(2000), clear; retain repeated monitoring and the stated event-history clearing policy. Imports and indentation must remain valid. Explain syntax versus runtime name failure versus valid but wrong sequence. Explain effects of untested defects using relevant examples, without claiming testing guarantees no errors. Saved corrected source and actual partner discussion or Pending. This retains source tasks 1 and 3; no numeric scores. Grown-up review; personal evidence is required.

    Worksheet 8

    1. Question 8: Flash your repaired revision to a micro:bit V2. Apply all three checks using a hand clap and a quiet starting condition. Give expected and actual results, including the exact order and waits, and a justified Pass/Fail or Pending. Record the file, method and any correction/retest. Keep simulator and source checks separate from physical microphone and speaker observations. Check activation by a loud hand clap; complete order is ENTERTAINER tune, then 500 ms wait, YES tick, 2000 ms wait, clear. The tune call completes before the half-second pause begins. Startup and inactive state are clear with no new tune when no loud event is recorded. Use V2 for the built-in microphone/speaker. The original program discards loud-event history at the end of its busy routine to avoid queuing its own sound; claps during that routine are also discarded. Record actual board/USB/audio evidence, or Pending; no fabricated observations. Compare the actual result to the requirement and retain any retest. Grown-up review; personal evidence is required.
    Back to my workbook ↑

    Curriculum & workbook reference

    Computing for your homeschool day

    Explore Identifying errors and debugging with this free Grade 7 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

    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.

    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.

    The book pages identify the related teaching topic. 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.