GRADE 7 · COMPUTING · UNIT 1 · LESSON 1.12

Block it out: Moving from blocks to text

Sub-routines

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

Sub-routines

Book extension, project or review · original companion practice

A sub-routine groups a named task so a larger algorithm can call it when needed. A main flowchart can choose a routine, pass control to it and then continue. Keep unsupported menu choices separate from valid operations, and check each routine as well as the route that calls it.

Today’s two goals
  • Explain how a main algorithm can call named sub-routines for repeated or separate tasks.
  • Trace a calculator flowchart through the main program and the selected sub-routine.
Original PaxaKids illustration for Sub-routines. 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 sub-routine groups a named task so a larger algorithm can call it when needed. A main flowchart can choose a routine, pass control to it and then continue. Keep unsupported menu choices separate from valid operations, and check each routine as well as the route that calls it.

Concept to practise: Sub-routines.

Work through an example

A menu uses 1 for Add and 2 for Subtract. With values 10 and 4, selecting 2 calls Subtract and produces 6. Selecting 3 must follow the unsupported-choice path; it must not silently call Add.

Try before your workbook

The menu uses 1 for Add and 2 for Subtract. What should happen for inputs 8 and 5 with choice 1, and what must the algorithm do with choice 7?

Check my readiness thinking

Choice 1 calls Add and returns 13. Choice 7 follows the specified unsupported-choice path. A routine's calculation and the decision selecting it are distinct parts of the algorithm.

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.

Give separate tasks clear names

Our goal: trace calls to named sub-routines, extend a calculator and repair a comparison algorithm.

A sub-routine groups steps that perform a task. A main algorithm can call it when needed. Keeping a task in one named place can make the design easier to read, reuse and change.

Follow the main calculator

Original routine-selection model
ConditionAction
operation == 1?Call Add
operation == 2?Call Subtract
OtherwiseOutput Unsupported

Read each routine’s job

Original routines
RoutineCalculation
Addresult = a + b
Subtractresult = a - b

Predict four basic-calculator cases

Predict four basic-calculator cases — original model
Caseaboperation
A832
B1471
C493
D6121

Plan two more operations

The extended calculator will recognise four operation choices. Add new decisions and named calls to the main algorithm, then define the Multiply and Divide routines. This lesson uses a non-zero b when dividing.
Plan two more operations — original model
ChoiceRoutineCalculation
1Addresult = a + b
2Subtractresult = a - b
3Multiplyresult = a * b
4Divideresult = a / b

Find the comparison-chart faults

Original routine-selection model
ConditionAction
a > b?Second bigger
b > a?Equal
OtherwiseOutput First bigger
Paxa the Fox

Try one step with Paxa!

Trace code carefully and preserve exact spelling, case and order. Use invented practice data. Save personal responses before leaving.

Our Unit 1 learning path
  1. Lesson 1.1: Comparing Scratch and Python
  2. Lesson 1.2: Using Python
  3. Lesson 1.3: Using Python IDLE in Script mode
  4. Lesson 1.4: Variables
  5. Lesson 1.5: Adding more information to a program
  6. Lesson 1.6: Data types – string, integer and real
  7. Lesson 1.7: Casting
  8. Lesson 1.8: Flowcharts and algorithms
  9. Lesson 1.9: BIDMAS in Python
  10. Lesson 1.10: Error detection and correction
  11. Lesson 1.11: Making choices IF THEN ELSE in flowcharts
  12. Lesson 1.12: Sub-routines
  13. Lesson 1.13: Random questions and a star number
  14. Lesson 1.14: Final project
  15. Lesson 1.15: Evaluation
  16. Lesson 1.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.

Sub-routines8 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 · 7.9 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: What does a sub-routine contain? steps for a named task
  2. Question 2: Why might a main algorithm call the same routine twice? to reuse its steps
  3. Question 3: Which flowchart symbol marks a call to a sub-routine? a rectangle with extra vertical side lines

Worksheet 2

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

Worksheet 3

  1. Question 4: Which routine does operation 2 call? Subtract
  2. Question 5: What does the Add routine calculate? a + b
  3. Question 6: Where does control go after a called routine returns? to the main algorithm’s continuation

Worksheet 4

  1. Question 7: What is output in case A? 5 / 5.0
  2. Question 8: What is output in case B? 21 / 21.0
  3. Question 9: What is output in case C? Unsupported
  4. Question 10: What is output in case D? 18 / 18.0

Worksheet 5

  1. Question 11: Where must a and b be entered? before a routine uses them
  2. Question 12: Which value of b must be excluded for ordinary division? 0

Worksheet 6

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

Worksheet 7

  1. Question 13: Draw the Multiply and Divide sub-routines. Attach an extended main flowchart that uses operation 1 to add, 2 to subtract, 3 to multiply and 4 to divide; other choices output Unsupported. Keep input before calculation and show return/continuation clearly. Trace (6,4,3), (15,6,4) and unsupported choice 9; peer-check the routes. Use a non-zero second number for division. Retain Add/Subtract routines from page C. Main inputs a,b,operation; checks options and calls only the matching named routine; unsupported option gives message then Stop. Multiply: result = a*b; output result; return. Divide: result = a/b; output result; return. Expected new tests 24;2.5;Unsupported. Existing add/sub traces remain 5,21,Unsupported in basic version,18; after extension former choice3 becomes supported. Require extended main as attached sheet/file and both new routine charts here, branch labels and call names, trace evidence and peer correction. Non-zero divisor stipulated; explicit zero guard accepted as extension. Grown-up review; personal evidence is required.

Worksheet 8

  1. Question 14: Redraw the faulty comparison chart from page F so it correctly reports First bigger, Second bigger or Equal. Keep both inputs before the decisions. Trace (12,5), (4,9) and (7,7), explain each output-label repair and record your peer checker’s findings. Correct first decision a>b: True output First bigger. False then test b>a: True output Second bigger, False output Equal. All routes merge to Stop. Equivalent correct decision order accepted with matching labels. Expected traces First bigger, Second bigger, Equal. In the faulty original adaptation, those same cases wrongly output Second bigger, Equal, First bigger. Require explanation linking each repaired label to the matching comparison and both True/False route labels; peer trace equality as well as unequal inputs. This is an original redrawing of the curriculum repair context, not a publisher figure. Grown-up review; personal evidence is required.
Back to my workbook ↑

Curriculum & workbook reference

Computing for your homeschool day

Explore Sub-routines 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.