GRADE 8 · COMPUTING · UNIT 1 · LESSON 1.29

Computational thinking and programming

Express constants in three algorithm forms

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

Topic 1.29 · Express constants in three algorithm forms12 fillable worksheet pagesRead at your own pace

LET’S TRACE, REASON AND TEST

Express constants in three algorithm forms

The same fixed value can be represented in a flowchart, pseudocode and Python. Preserve its meaning and use across representations rather than copying only the spelling of the commands.

Today’s two goals
  • Connect a flowchart, pseudocode and Python using the same fixed rules.
  • Explain my method and support it with a labelled trace, example or test record.
Original PaxaKids illustration for Express constants in three algorithm forms. 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 plan that sets RATE to 4 and calculates charge = hours × RATE should give the same result in all three forms. For 3 hours, the modelled charge is 12.

Try before your workbook

If a diagram uses RATE 4 but the Python version uses 5, are the two versions equivalent for 3 hours?

Explore the clues

Tap one card to find out more.

Understand the idea

The same fixed value can be represented in a flowchart, pseudocode and Python. Preserve its meaning and use across representations rather than copying only the spelling of the commands.

Concept to practise: Express constants in three algorithm forms.

Work through an example

A plan that sets RATE to 4 and calculates charge = hours × RATE should give the same result in all three forms. For 3 hours, the modelled charge is 12.

Try before your workbook

If a diagram uses RATE 4 but the Python version uses 5, are the two versions equivalent for 3 hours?

Check my readiness thinking

No. They produce 12 and 15 respectively. Compare behaviour and constants as well as the visible sequence.

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.

Keep one rule across three representations

A flowchart, pseudocode and Python can express the same algorithm. Keep each fixed value, calculation, input order and output consistent when translating.

This workbook uses original packing, fictional token-rate and model-building examples. All numeric inputs are valid nonnegative integers. Constants stay fixed during each run by design; uppercase Python names communicate that intention.

Compare packing pseudocode with Python

Each pack contains six items. Read a whole-number pack count, multiply it by the fixed pack size and output the total. Both versions define the setting before using it.
Pseudocode convention
CONSTANT ITEMS_PER_PACK = 6
INPUT packs
items = packs * ITEMS_PER_PACK
OUTPUT items
Executable Python
ITEMS_PER_PACK = 6
packs = int(input())
items = packs * ITEMS_PER_PACK
print(items)

Follow the equivalent packing flowchart

Read the arrows from Start to Stop. The constant declaration and calculation are processes. Input and output use parallelograms. For valid integer input, this flowchart has the same behaviour as both page 2 versions.
Follow the equivalent packing flowchart — original labelled workbook model. The following text version gives its labels and values.
Follow the equivalent packing flowchart · original PaxaKids model.
Read this model’s labels and values
Node height
13
Gap
5
Width
133
Nodes
    1. start
    2. Start
    1. process
    2. CONSTANT ITEMS_PER_PACK = 6
    1. input
    2. INPUT packs
    1. process
    2. items = packs * ITEMS_PER_PACK
    1. output
    2. OUTPUT items
    1. stop
    2. Stop

Check equivalent packing totals

Treat each row as a fresh run of the algorithm on pages 2–3. The fixed setting is 6 throughout every run; only the input packs changes.
Check equivalent packing totals — original model
Input packsPredicted output items
0{'clue': 'Exact output', 'prompt': 'Packing total for zero packs', 'answers': ['0']}
1{'clue': 'Exact output', 'prompt': 'Packing total for one pack', 'answers': ['6']}
3{'clue': 'Exact output', 'prompt': 'Packing total for three packs', 'answers': ['18']}
8{'clue': 'Exact output', 'prompt': 'Packing total for eight packs', 'answers': ['48']}

Use a numeric constant and a text constant

The rate is 1.5 fictional tokens per unit. LABEL stores the repeated text. Read the first quantity, output its result, then read the second quantity and output its result. Keep that input/output order when translating.
Pseudocode convention
CONSTANT TOKEN_RATE = 1.5
CONSTANT LABEL = "Tokens:"
INPUT first_units
OUTPUT LABEL, first_units * TOKEN_RATE
INPUT second_units
OUTPUT LABEL, second_units * TOKEN_RATE
Executable Python
TOKEN_RATE = 1.5
LABEL = "Tokens:"
first_units = int(input())
print(LABEL, first_units * TOKEN_RATE)
second_units = int(input())
print(LABEL, second_units * TOKEN_RATE)

Trace a complete two-constant flowchart

Both fixed settings are declared together before either input. The two output steps use the same rate and label. Follow the first input/output pair before the second pair.
Trace a complete two-constant flowchart — original labelled workbook model. The following text version gives its labels and values.
Trace a complete two-constant flowchart · original PaxaKids model.
Read this model’s labels and values
Node height
16
Gap
4
Width
142
Nodes
    1. start
    2. Start
    1. process
    2. CONSTANT TOKEN_RATE = 1.5
      CONSTANT LABEL = "Tokens:"
    1. input
    2. INPUT first_units
    1. output
    2. OUTPUT LABEL,
      first_units * TOKEN_RATE
    1. input
    2. INPUT second_units
    1. output
    2. OUTPUT LABEL,
      second_units * TOKEN_RATE
    1. stop
    2. Stop

Compare maintenance with and without constants

For the literal version shown here, changing the rate from 1.5 to 2.0 requires two replacements. In the named version on page 5, edit only TOKEN_RATE. Likewise, changing Tokens: to Total tokens: requires two literal edits or one LABEL edit. Retest both outputs after either change.
Original program model
first_units = int(input())
print("Tokens:", first_units * 1.5)
second_units = int(input())
print("Tokens:", second_units * 1.5)

Choose types for fixed and changing data

Use Python type names int, float, str and bool. The example value determines the stored Python type here, while the meaning explains why that type is useful. Quotation marks indicate string values.
Choose types for fixed and changing data — original model
NameExample valuePython type
ITEMS_PER_PACK6{'clue': 'int / float / str / bool', 'prompt': 'Type of ITEMS_PER_PACK', 'answers': ['int', 'integer']}
TOKEN_RATE1.5{'clue': 'int / float / str / bool', 'prompt': 'Type of TOKEN_RATE', 'answers': ['float', 'real']}
LABEL"Tokens:"{'clue': 'int / float / str / bool', 'prompt': 'Type of LABEL', 'answers': ['str', 'string']}
packs3{'clue': 'int / float / str / bool', 'prompt': 'Type of packs', 'answers': ['int', 'integer']}
readyTrue{'clue': 'int / float / str / bool', 'prompt': 'Type of ready', 'answers': ['bool', 'Boolean']}

Plan three named decision thresholds

This original model-building policy uses fictional piece counts, not learner marks. A valid nonnegative integer pieces input selects exactly one message, testing the highest threshold first. Translate this complete pseudocode into a flowchart and Python in the final task.
Original Paxa model-size policy
CONSTANT LARGE_MIN = 60
CONSTANT MEDIUM_MIN = 35
CONSTANT SMALL_MIN = 15
INPUT pieces
IF pieces >= LARGE_MIN THEN
    OUTPUT "Large model"
ELSEIF pieces >= MEDIUM_MIN THEN
    OUTPUT "Medium model"
ELSEIF pieces >= SMALL_MIN THEN
    OUTPUT "Small model"
ELSE
    OUTPUT "Collect more pieces"
ENDIF

Test immediately below and at every threshold

Use page 9 without changing its fixed settings. These six inputs test each exact boundary and its nearest smaller integer. Write only the selected message.
Test immediately below and at every threshold — original model
Input piecesSelected message
14{'clue': 'Exact message', 'prompt': 'Model message for 14', 'answers': ['Collect more pieces']}
15{'clue': 'Exact message', 'prompt': 'Model message for 15', 'answers': ['Small model']}
34{'clue': 'Exact message', 'prompt': 'Model message for 34', 'answers': ['Small model']}
35{'clue': 'Exact message', 'prompt': 'Model message for 35', 'answers': ['Medium model']}
59{'clue': 'Exact message', 'prompt': 'Model message for 59', 'answers': ['Medium model']}
60{'clue': 'Exact message', 'prompt': 'Model message for 60', 'answers': ['Large model']}

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.

Express constants in three algorithm forms12 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 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 · 7.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 12 worksheets

Worksheet 1

  1. Question 1: What must stay consistent across equivalent representations? fixed values, input order, calculations and outputs
  2. Question 2: Which Python line follows the intended constant naming convention? ITEMS_PER_PACK = 6

Worksheet 2

  1. Question 3: Which identifier represents the fixed pack size? ITEMS_PER_PACK
  2. Question 4: Which Python expression reads and converts the pack count? int(input())
  3. Question 5: For 3 packs, what total is output? 18

Worksheet 3

  1. Question 6: Which shape contains the constant declaration? a process rectangle

Worksheet 4

  1. Question 7: Packing total for zero packs 0
  2. Question 8: Packing total for one pack 6
  3. Question 9: Packing total for three packs 18
  4. Question 10: Packing total for eight packs 48
  5. Question 11: If the specification changes to 8 items per pack between runs, which definition changes? ITEMS_PER_PACK = 8

Worksheet 5

  1. Question 12: Which constant stores text? LABEL
  2. Question 13: For inputs 4 then 6, what is the second calculated token amount? 9.0 / 9

Worksheet 6

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

Worksheet 7

  1. Question 14: How many numeric literal occurrences must change in the displayed version? 2
  2. Question 15: How many LABEL definitions change in the named version? 1

Worksheet 8

  1. Question 16: Type of ITEMS_PER_PACK int / integer
  2. Question 17: Type of TOKEN_RATE float / real
  3. Question 18: Type of LABEL str / string
  4. Question 19: Type of packs int / integer
  5. Question 20: Type of ready bool / Boolean

Worksheet 9

  1. Question 21: Which constant holds the medium-model threshold? MEDIUM_MIN
  2. Question 22: Why test LARGE_MIN before SMALL_MIN? a large count also meets the smaller thresholds

Worksheet 10

  1. Question 23: Model message for 14 Collect more pieces
  2. Question 24: Model message for 15 Small model
  3. Question 25: Model message for 34 Small model
  4. Question 26: Model message for 35 Medium model
  5. Question 27: Model message for 59 Medium model
  6. Question 28: Model message for 60 Large model

Worksheet 11

  1. Question 29: Use the complete page 9 policy. First draw its original equivalent flowchart using literal thresholds 60, 35 and 15. Then add named constant declarations and replace each threshold literal in the decisions with its matching name. Write equivalent Python from the pseudocode, with the same four messages and ordered comparisons. Test all six page 10 inputs, recording predictions and actual outputs or Pending. Identify the changing input, the three fixed integer settings and any corrections. Keep both flowchart versions, full code and test records; explain how the representations express the same rule. Original flowchart: Start/input, ordered >=60/>=35/>=15 decisions, labelled True/False branches to Large model/Medium model/Small model/Collect more pieces, rejoin Stop. Modified flowchart defines LARGE_MIN=60, MEDIUM_MIN=35, SMALL_MIN=15 in process rectangle before tests and uses names. Python valid int(input()), if/elif/elif/else colons and indented print; uppercase names by convention, no CONSTANT keyword. Boundary results 14 Collect more pieces;15/34 Small model;35/59 Medium model;60 Large model. One output per run, values/int roles, exact equivalence, actual/Pending and correction/retest evidence. Full diagrams/source may be attached, not cramped into this response area. Grown-up review; personal evidence is required.

Worksheet 12

  1. Question 30: Create an original Choosing a data type worksheet with at least six fictional data examples, including a numeric-looking code, a whole-number count, a decimal quantity, a one-character string and a Boolean flag. Add a short algorithm that stores data in variables and named constants. Ask readers to choose each suitable type and explain its purpose. Prepare a separate answer key with reasons. Exchange with another pair if available, record real feedback and improve one item; otherwise complete an individual review and mark the exchange Pending. Keep the worksheet, key and review evidence with this workbook. At least six original fictional examples, clear intended operations and appropriate int/float/str/bool. Code such as "0042" preserved as str, count int, fractional quantity float, single character str length one in Python, genuine Boolean True/False distinct from quoted text. Short coherent algorithm includes changing variable and meaningful fixed constant, key explains types and role. Complete worksheet and separate answers included/cited. Actual pair exchange/feedback and revision or truthful individual review with exchange Pending; no numeric grading, invented peer confirmation or missing-source dependency. Grown-up review; personal evidence is required.
Back to my workbook ↑

Curriculum & workbook reference

Computing for your homeschool day

Explore Express constants in three algorithm forms 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.