GRADE 8 · COMPUTING · UNIT 1 · LESSON 1.32

Computational thinking and programming

Recall calls and trace return values

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

Topic 1.32 · Recall calls and trace return values14 fillable worksheet pagesRead at your own pace

LET’S TRACE, REASON AND TEST

Recall calls and trace return values

A function call runs a routine, and return passes a result back to its caller. Assigning or using that result is different from the routine merely printing a message. Trace the call and the return destination.

Today’s two goals
  • Trace shape sub-routines and Python functions; show what a return supplies to the caller.
  • Explain my method and support it with a labelled trace, example or test record.
Original PaxaKids illustration for Recall calls and trace return values. 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

If double(n) returns n × 2, then result = double(7) assigns 14 to result. Printing 14 inside a routine alone would not be the same as returning it.

Try before your workbook

If add_one(8) returns 9 but the caller ignores the result, has a caller variable automatically changed?

Explore the clues

Tap one card to find out more.

Understand the idea

A function call runs a routine, and return passes a result back to its caller. Assigning or using that result is different from the routine merely printing a message. Trace the call and the return destination.

Concept to practise: Recall calls and trace return values.

Work through an example

If double(n) returns n × 2, then result = double(7) assigns 14 to result. Printing 14 inside a routine alone would not be the same as returning it.

Try before your workbook

If add_one(8) returns 9 but the caller ignores the result, has a caller variable automatically changed?

Check my readiness thinking

No. The caller must assign or otherwise use the returned result. Track the return value separately from any displayed output.

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.

Call a named routine and resume the caller

A sub-routine is a named part of an algorithm that can be called from elsewhere. A call transfers control to that routine; when it finishes, control returns to the caller.

A function can return a value for the caller to store, print or use in a calculation. Defining a function sets it up; its body runs when it is called. We will trace calls and returned values with complete original examples.

Follow a call and its returned value

The two arrows show distinct directions: the caller calls make_reply(), then the function returns a value. The caller receives that value in reply and continues.
Follow a call and its returned value — original labelled workbook model. The following text version gives its labels and values.
Follow a call and its returned value · original PaxaKids model.
Read this model’s labels and values

Trace definition, call and continuation

Read the complete program. The return is inside make_reply; unindented print statements belong to the main program. Predict the printed lines in order.
Original Paxa function-return program
def make_reply():
    return "Ready"
print("Before")
reply = make_reply()
print(reply)
print("After")

Select a shape-report sub-routine

Enter square or rectangle exactly in lowercase. A matching branch calls its named report routine, then the caller reaches Stop. Another choice prints Invalid choice without reading any dimensions.
Select a shape-report sub-routine — original labelled workbook model. The following text version gives its labels and values.
Select a shape-report sub-routine · original PaxaKids model.
Read this model’s labels and values
Before
    1. start
    2. Start
    1. output
    2. OUTPUT Choose square or rectangle
    1. input
    2. INPUT shape
Routes
    1. shape = "square"
    2. call
    3. square_report()
    1. shape = "rectangle"
    2. call
    3. rectangle_report()
Otherwise
OUTPUT "Invalid choice"

Read the two separately defined report routines

These original routine diagrams use the same positive whole-number dimension inputs and calculations as the packaged Python program. Their final Return to caller means the routine finishes; it does not stop the main program.
Read the two separately defined report routines — original labelled workbook model. The following text version gives its labels and values.
Read the two separately defined report routines · original PaxaKids model.
Read this model’s labels and values

Trace shape area and perimeter reports

Use pages 4–5. Dimensions use one common length unit. Write numeric area and perimeter values; the area is in square units and the perimeter is in length units. Each row is a fresh run.
Trace shape area and perimeter reports — original model
Shape and dimensionsAreaPerimeter
square, side 3{'clue': 'Exact value', 'prompt': 'Square side3 area', 'answers': ['9']}{'clue': 'Exact value', 'prompt': 'Square side3 perimeter', 'answers': ['12']}
square, side 5{'clue': 'Exact value', 'prompt': 'Square side5 area', 'answers': ['25']}{'clue': 'Exact value', 'prompt': 'Square side5 perimeter', 'answers': ['20']}
rectangle, length 8, width 3{'clue': 'Exact value', 'prompt': 'Rectangle8by3 area', 'answers': ['24']}{'clue': 'Exact value', 'prompt': 'Rectangle8by3 perimeter', 'answers': ['22']}
rectangle, length 6, width 2{'clue': 'Exact value', 'prompt': 'Rectangle6by2 area', 'answers': ['12']}{'clue': 'Exact value', 'prompt': 'Rectangle6by2 perimeter', 'answers': ['16']}

Model a caller and a function with two roles

In a role-play, the caller asks for the result of 6 * 7. The function role works out 42 and returns that value. The caller then uses it: Six packs hold 42 items. The sentence is the caller’s output, while 42 is the returned value.

Swap roles and use the original question 9 + 8. Individuals can trace and explain both roles on paper; record any real paired round or mark it Pending in the final task.

Recognise valid Python definitions and calls

Python def is followed by a valid identifier, parentheses and a colon. The body is indented. Names may contain underscores and digits after a valid starting character; spaces and an initial digit are not allowed. Follow clear lowercase names with underscores in these examples.
Original Paxa valid syntax
def read_colour():
    colour = input()
    return colour
chosen_colour = read_colour()

Read two functions that return entered text

This original program reads a fictional code and a colour, keeping input local to each called function. Each function returns the entered string; the caller stores it under its own meaningful name. Use Orbit then teal as the two input lines.
Original Paxa two-function return example
def read_code():
    print("Enter a fictional code")
    code = input()
    return code
def read_colour():
    print("Enter a colour")
    colour = input()
    return colour
print("Start")
mission_code = read_code()
print("Code:", mission_code)
chosen_colour = read_colour()
print("Colour:", chosen_colour)
print("End")

Trace returned values and final output order

Use page 9 with input Orbit followed by teal. Include only the requested value or output text in each response. The input prompts are printed by the called functions before those inputs are read.
Trace returned values and final output order — original model
Trace pointStored value or printed line
First main-program output{'clue': 'Exact line', 'prompt': 'First two-function output', 'answers': ['Start']}
Value returned by read_code(){'clue': 'Text value', 'prompt': 'Returned mission code', 'answers': ['Orbit']}
Output after storing mission_code{'clue': 'Exact line', 'prompt': 'Code report line', 'answers': ['Code: Orbit']}
Value returned by read_colour(){'clue': 'Text value', 'prompt': 'Returned colour', 'answers': ['teal']}
Last main-program output{'clue': 'Exact line', 'prompt': 'Final two-function output', 'answers': ['End']}

Distinguish printing from returning

Version A returns text for its caller to print. Version B prints text inside the function and has no explicit return. In Python it therefore returns None, which the final caller print displays. This follows the Python function guide.
A: return a useful value
def get_word():
    return "Ready"
result = get_word()
print(result)
B: print inside the function
def show_word():
    print("Ready")
result = show_word()
print(result)

Check a call that is defined but never made

Compare the complete versions. A defines a function but does not call it; B calls the function after its definition. Both then continue with the main-program print.
A: no call
def signal():
    print("Inside")
print("Outside")
B: one call
def signal():
    print("Inside")
signal()
print("Outside")

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.

Recall calls and trace return values14 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.0 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: What triggers execution of the defined function body? calling the function
  2. Question 2: Where does control resume after a normal completed call? in the caller after the call

Worksheet 2

  1. Question 3: What text is returned by make_reply()? Ready
  2. Question 4: Which caller variable receives that text? reply

Worksheet 3

  1. Question 5: What is the first printed line? Before
  2. Question 6: What is the second printed line? Ready
  3. Question 7: What is the third printed line? After
  4. Question 8: Does return "Ready" itself print Ready? no, the caller print displays the returned text

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 9: Square side3 area 9
  2. Question 10: Square side3 perimeter 12
  3. Question 11: Square side5 area 25
  4. Question 12: Square side5 perimeter 20
  5. Question 13: Rectangle8by3 area 24
  6. Question 14: Rectangle8by3 perimeter 22
  7. Question 15: Rectangle6by2 area 12
  8. Question 16: Rectangle6by2 perimeter 16

Worksheet 7

  1. Question 17: What value is returned for 9 + 8? 17
  2. Question 18: Who uses the returned value in a sentence in this model? the caller
  3. Question 19: Which is an honest record if no partner round occurred? an individual trace and paired activity marked Pending

Worksheet 8

  1. Question 20: Which is a valid function definition header? def read_colour():
  2. Question 21: Which line calls the defined function? chosen_colour = read_colour()
  3. Question 22: Which line belongs inside the function body? return colour, indented under def

Worksheet 9

  1. Question 23: Which caller variable stores the result of read_code()? mission_code
  2. Question 24: Which caller variable stores the result of read_colour()? chosen_colour

Worksheet 10

  1. Question 25: First two-function output Start
  2. Question 26: Returned mission code Orbit
  3. Question 27: Code report line Code: Orbit
  4. Question 28: Returned colour teal
  5. Question 29: Final two-function output End

Worksheet 11

  1. Question 30: How many output lines does A print? 1
  2. Question 31: What is B’s second printed line? None
  3. Question 32: Does a Python function without explicit return stop being a function? no, it returns None when it reaches the end

Worksheet 12

  1. Question 33: What is A’s only printed line? Outside
  2. Question 34: What is B’s first printed line? Inside
  3. Question 35: What is B’s second printed line? Outside

Worksheet 13

  1. Question 36: Identify the two called routine names on page 4. Trace the main flow and both page 5 reports for all four page 6 cases, then use the supplied complete shape_reports_paxa.py to check predictions if execution is available. Add an invalid choice triangle and explain why no dimension input is then read. Record exact printed messages and actual results or Pending. Annotate where control enters a routine and resumes the caller. Keep source, traces and tests; explain area/perimeter units and any correction or actual individual/partner work. Routine identifiers square_report and rectangle_report. Square sides3/5 -> Area:9/25 and Perimeter:12/20; rectangle8by3/6by2 -> Area:24/12 and Perimeter:22/16, with exact print spacing. Main first prints Choose square or rectangle. triangle -> Invalid choice, no dimension reads; chosen routine finishes and control returns to caller before program ends. Positive integer dimensions, common length units, area square units/perimeter length units. Full source/traces/predictions/actual or Pending and correction/retest, truthful work evidence. No shape hardware or pair activity inferred. Grown-up review; personal evidence is required.

Worksheet 14

  1. Question 37: Model both page 7 arithmetic questions as caller/function exchanges, swapping roles if a partner is available or tracing both roles individually. Record the returned value and the caller’s sentence for each; mark an unperformed paired round Pending. Then trace the complete page 9 program for fictional code Nova and colour amber, showing both returned values, caller assignments and every printed line. Run if available or mark execution Pending. Explain why return differs from print, using page 11 evidence, and state one correction or next step. Keep full records and source. Roleplay6*7 ->42 and9+8 ->17; caller uses each numeric result in a meaningful sentence. Actual swap/observations or honest individual trace with paired Pending. Two-function full output Start;Enter a fictional code;Code: Nova;Enter a colour;Colour: amber;End. Local code/colour returned as str and stored mission_code/chosen_colour. return sends value back; print displays output; print-only function implicitly returns None, demonstrated by page11B. Definition not execution, caller resumes, full traces/source/actual or Pending, correction/next step and truthful support/roles. Grown-up review; personal evidence is required.
Back to my workbook ↑

Curriculum & workbook reference

Computing for your homeschool day

Explore Recall calls and trace return values 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.