Subroutines and FunctionsActivities & Teaching Strategies
Active learning helps Year 10 students see how subroutines and functions reduce repetition and clarify logic in programs. Working in pairs, groups, and individually builds fluency with modular design, making abstract concepts concrete through shared problem-solving and peer feedback.
Learning Objectives
- 1Analyze program logic to identify opportunities for code modularization using subroutines and functions.
- 2Compare and contrast the behavior of procedures and functions, explaining the significance of return values.
- 3Design a program structure for a given problem, effectively decomposing it into multiple, well-defined subroutines.
- 4Evaluate the impact of using subroutines on code readability, maintainability, and reusability.
- 5Create Python code that implements both procedures and functions to solve a multi-step problem.
Want a complete lesson plan with these objectives? Generate a Mission →
Pair Programming: Modular Menu System
Pairs create a text-based menu program. Write procedures for displaying options and handling user choices, plus a function to validate inputs. Test the full program with sample runs and swap code for peer review.
Prepare & details
Justify the use of subroutines to improve code readability and maintainability.
Facilitation Tip: During Pair Programming, circulate to prompt partners to alternate the driver role every four lines of code to share cognitive load.
Setup: Flexible seating for regrouping
Materials: Expert group reading packets, Note-taking template, Summary graphic organizer
Small Groups: Refactor Challenge
Provide groups with linear 'spaghetti' code for a quiz game. Identify repeated tasks and convert them into procedures and functions. Groups present their modular versions, explaining improvements in readability.
Prepare & details
Differentiate between a procedure and a function based on their return values.
Facilitation Tip: In the Refactor Challenge, provide colored highlighters so groups mark reused blocks before rewriting them as subroutines.
Setup: Flexible seating for regrouping
Materials: Expert group reading packets, Note-taking template, Summary graphic organizer
Whole Class: Function Trace Relay
Project a program with multiple functions. Divide class into teams; each traces one function's execution path on paper. Teams share findings to reconstruct the full flow and fix errors.
Prepare & details
Design a program structure using multiple subroutines to perform distinct tasks.
Facilitation Tip: During the Function Trace Relay, give each student a unique colored pen to annotate the execution path on the whiteboard.
Setup: Flexible seating for regrouping
Materials: Expert group reading packets, Note-taking template, Summary graphic organizer
Individual: Subroutine Design Blueprint
Students outline a program for sorting student scores using pseudocode. Define 4-5 subroutines or functions with parameters and returns. Share blueprints for class feedback before coding.
Prepare & details
Justify the use of subroutines to improve code readability and maintainability.
Facilitation Tip: For the Subroutine Design Blueprint, remind students to label inputs, outputs, and side effects before writing any code.
Setup: Flexible seating for regrouping
Materials: Expert group reading packets, Note-taking template, Summary graphic organizer
Teaching This Topic
Teach procedures first as “tasks without answers,” then functions as “tasks with answers.” Use live coding to model both, deliberately making mistakes and fixing them together. Research shows tracing by hand on paper or whiteboards strengthens mental models more than passive reading. Avoid jumping straight to definitions; anchor understanding in solving small, familiar problems before naming the concepts.
What to Expect
Students will justify their choices of procedures and functions, trace code execution accurately, and refactor messy snippets into clean modules. Successful learning shows in clear explanations, correct outputs, and confident discussions about readability and maintenance.
These activities are a starting point. A full mission is the experience.
- Complete facilitation script with teacher dialogue
- Printable student materials, ready for class
- Differentiation strategies for every learner
Watch Out for These Misconceptions
Common MisconceptionDuring Pair Programming, watch for students who treat procedures and functions as interchangeable.
What to Teach Instead
Ask one partner to add a print statement inside the supposed function while the other traces the flow. If no value is returned, highlight the missing return statement and discuss why a function without a return is only a procedure in disguise.
Common MisconceptionDuring Refactor Challenge, watch for students who claim subroutines slow down small programs.
What to Teach Instead
Ask groups to time both the original and refactored versions on their machines. Have them change a single line in the original and in the refactored code, timing the edits to show local changes reduce debugging time.
Common MisconceptionDuring Function Trace Relay, watch for students who assume functions only return numbers.
What to Teach Instead
Insert a function that returns a string or boolean into the trace. Pause the relay to ask students to predict the type and justify their answer before running the code.
Assessment Ideas
After Pair Programming, distribute a short Python snippet that mixes a procedure and a function. Ask students to label each, explain whether it returns a value, and write the expected output in their books before leaving.
During Refactor Challenge, circulate with a checklist asking each group to show you their pseudocode for a calculation function and a display procedure before they write the actual code.
After the Subroutine Design Blueprint, facilitate a whole-class discussion where three volunteers share their library tasks and justify whether each should be a procedure or function, using the blueprint as evidence.
Extensions & Scaffolding
- Challenge: Add error handling to one of the refactored functions so it returns meaningful messages instead of crashing.
- Scaffolding: Provide a partially completed subroutine with comments guiding where to insert parameters and returns.
- Deeper exploration: Ask students to compare two sorting algorithms, one implemented with functions and one without, measuring lines of code and perceived readability.
Key Vocabulary
| Subroutine | A block of code designed to perform a specific task. It can be called from other parts of the program without rewriting the code. |
| Procedure | A type of subroutine that performs a task but does not return a value to the calling code. It is used for actions or commands. |
| Function | A type of subroutine that performs a task and returns a value to the calling code. It is used for calculations or data retrieval. |
| Call | The act of executing a subroutine or function from another part of the program. This transfers control to the subroutine. |
| Return Value | The data that a function sends back to the part of the program that called it. Procedures do not have return values. |
Suggested Methodologies
More in The Art of Programming
Sequence: The Order of Execution
Understanding that instructions are executed in a specific order.
2 methodologies
Selection: Conditional Logic (If/Else)
Implementing 'if', 'else if', and 'else' statements to control program flow.
2 methodologies
Selection: Case Statements
Using case statements (or switch statements) for multi-way branching.
2 methodologies
Iteration: Fixed Loops (For)
Using 'for' loops to repeat a block of code a predetermined number of times.
2 methodologies
Iteration: Conditional Loops (While)
Using 'while' loops to repeat a block of code until a condition is met.
2 methodologies
Ready to teach Subroutines and Functions?
Generate a full mission with everything you need
Generate a Mission