GRADE 7 · COMPUTING · UNIT 2 · LESSON 2.8

Decomposing problems: Creating a smart solution

Algorithmic solutions and data types

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

7 fillable worksheet pagesRead at your own pace

LET’S TRACE, REASON AND TEST

Algorithmic solutions and data types

A value's type affects how a program uses it. "12" is a string and 12 is an integer. Sensor API results are not all integers: numeric readings and Boolean predicates have different roles. Match the value and comparison to the API rather than assuming a type from its name.

Today’s two goals
  • Distinguish quoted strings from integer values in the supplied examples.
  • Identify the numeric sound-level reading used in the source comparison and predict the output.
Original PaxaKids illustration for Algorithmic solutions and data types. 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

A value's type affects how a program uses it. "12" is a string and 12 is an integer. Sensor API results are not all integers: numeric readings and Boolean predicates have different roles. Match the value and comparison to the API rather than assuming a type from its name.

Concept to practise: Algorithmic solutions and data types.

Work through an example

A numeric sound reading can be compared with 150. A result such as True from a touch test is Boolean, not the word "True" and not a sound-level measurement. Quotation marks change the type and meaning.

Try before your workbook

Classify 24, "24" and True. Which one is appropriate for arithmetic, and which directly answers a yes-or-no condition?

Check my readiness thinking

24 is an integer, "24" is a string and True is Boolean. The integer suits numeric arithmetic; the Boolean directly represents a condition result. A numeric string needs suitable conversion first.

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.

Match the data type to the task

Our goal: distinguish strings and integers, trace a numeric sound-level condition and repair a sensor program.

Quotation marks create a string literal. An unquoted whole-number literal such as 24 is an integer. A sound-level measurement is numeric; a question such as “was a loud event detected?” returns a Boolean.

Plan the sound-level response: V2

    Decision: level > 150?

    True branch
    1. Show SURPRISED
    False branch
    1. Show HAPPY

    Compare the original starter with the plan

    ORIGINAL FAULTY SOUND PROGRAM: V2
    from microbit import *
    
    while True:
        level = microphone.sound_level()
        if level < 150:
            display.show(Image.SURPRISED)
        else:
            display.show(Image.HAPPY)
        sleep(100)
    Paxa the Fox

    Try one step with Paxa!

    Use the API for the chosen editor. Label paper traces, simulator runs and physical tests accurately; ask a grown-up before connecting equipment. Save personal responses before leaving.

    Our Unit 2 learning path
    1. Lesson 2.1: All about software
    2. Lesson 2.2: Introducing the micro:bit
    3. Lesson 2.3: Using Python with the micro:bit
    4. Lesson 2.4: The micro:bit Python environment
    5. Lesson 2.5: Correcting errors using a flowchart
    6. Lesson 2.6: Using sensors in programming
    7. Lesson 2.7: Flowcharts for algorithm planning
    8. Lesson 2.8: Algorithmic solutions and data types
    9. Lesson 2.9: Planning a smart solution
    10. Lesson 2.10: Effective testing
    11. Lesson 2.11: Evaluating a program
    12. Lesson 2.12: Testing accelerometer gestures
    13. Lesson 2.13: Protecting a museum crown
    14. Lesson 2.14: Final project
    15. Lesson 2.15: Evaluation
    16. Lesson 2.16: 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.

    Algorithmic solutions and data types7 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 7 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 7 worksheets

    Worksheet 1

    1. Question 1: What is the type of "24"? string
    2. Question 2: What is the type of the unquoted value 24? integer

    Worksheet 2

    1. Question 3: Classify 12. integer / int
    2. Question 4: Classify "Pass123". string / str
    3. Question 5: Classify 'light'. string / str
    4. Question 6: Classify 3456. integer / int
    5. Question 7: Which comparison is suitable for a numeric reading in level? level > 150

    Worksheet 3

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

    Worksheet 4

    1. Question 8: Which image is shown for 160? SURPRISED
    2. Question 9: Which image is shown for 86? HAPPY
    3. Question 10: Which image is shown for 200? SURPRISED
    4. Question 11: Which image is shown for 51? HAPPY
    5. Question 12: Which image is shown at exactly 150? HAPPY

    Worksheet 5

    1. Question 13: Which call supplies the numeric reading needed here? microphone.sound_level()

    Worksheet 6

    1. Question 14: Repair the wrong comparison. Explain the difference between the numeric sound reading, its >150 comparison result and a quoted string such as "150". Trace 149, 150 and 151 through your corrected program. Explain why substituting a True/False event test for the numeric reading would not implement this algorithm. Correct if level > 150. microphone.sound_level() returns numeric relative reading 0–255; condition level > 150 returns Boolean. "150" is string, not the numeric threshold. 149 and 150: HAPPY; 151: SURPRISED. Both paths rejoin, pause 100 ms, then read a new level; correct MicroPython names/indentation and V2. Event predicate is Boolean rather than measured sound magnitude; it does not supply this numeric scale or implement threshold 150. Preserve exact supported Image members. All source-required 160/86/200/51 predictions are SURPRISED/HAPPY/SURPRISED/HAPPY. Accept clear correct program and explanation; no numeric scoring. Grown-up review; personal evidence is required.

    Worksheet 7

    1. Question 15: Record both partners’ roles, the corrected source revision and the transfer method. Test quieter and louder conditions that produce readings on both sides of 150. Record actual readings, expected and observed images, pass/fail and any repair/retest. Explain whether both outputs matched the plan. Keep simulated trials separate from the required physical-board demonstration. Require saved corrected source, identified V2 board and actual completed transfer; partner roles described and swapped. Record measured conditions/readings 150 with expected and observed HAPPY/SURPRISED respectively, pass/fail and repairs/retests. Values 160/86/200/51 are paper traces, not invented physical readings. Use ordinary classroom sound and adjust conditions; do not assume ambient sound can be set precisely. If only one branch reached, say so and leave other test pending. No V2/board access: physical evidence pending; simulator-only work labelled preparation. No claim of physical success based on stub tests. Reasoned judgement links observed outputs to requirement, not a numeric score. Grown-up review; personal evidence is required.
    Back to my workbook ↑

    Curriculum & workbook reference

    Computing for your homeschool day

    Explore Algorithmic solutions and data types 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.