Skip to content
Computing · Year 10 · The Art of Programming · Summer Term

Subroutines and Functions

Modularizing code using subroutines (procedures) and functions.

National Curriculum Attainment TargetsGCSE: Computing - Programming Fundamentals

About This Topic

Subroutines and functions help students modularize code by dividing programs into smaller, focused blocks. Procedures carry out tasks without returning values, such as displaying output or updating variables. Functions compute results and return them to the main program, like calculating an average. Year 10 learners justify these tools for better readability and easier maintenance, meeting GCSE Computing standards in programming fundamentals.

In the Art of Programming unit, students differentiate procedures from functions by their return values and design structures with multiple subroutines for separate tasks, such as input validation or data processing. This practice strengthens decomposition and abstraction, core computational thinking skills essential for software development.

Active learning suits this topic well because students write, call, and test code live in editors. They see instant feedback on how subroutines simplify debugging and reuse, while pair refactoring turns abstract benefits into concrete gains. Collaborative challenges build confidence in structuring complex programs.

Key Questions

  1. Justify the use of subroutines to improve code readability and maintainability.
  2. Differentiate between a procedure and a function based on their return values.
  3. Design a program structure using multiple subroutines to perform distinct tasks.

Learning Objectives

  • Analyze program logic to identify opportunities for code modularization using subroutines and functions.
  • Compare and contrast the behavior of procedures and functions, explaining the significance of return values.
  • Design a program structure for a given problem, effectively decomposing it into multiple, well-defined subroutines.
  • Evaluate the impact of using subroutines on code readability, maintainability, and reusability.
  • Create Python code that implements both procedures and functions to solve a multi-step problem.

Before You Start

Variables and Data Types

Why: Students need to understand how to store and manipulate data to effectively use return values from functions.

Basic Control Flow (If Statements, Loops)

Why: Students must be familiar with how to structure code execution before they can understand how to call and manage subroutines.

Input and Output Operations

Why: Understanding how programs receive input and display output is fundamental to grasping the purpose of procedures that perform these actions.

Key Vocabulary

SubroutineA block of code designed to perform a specific task. It can be called from other parts of the program without rewriting the code.
ProcedureA type of subroutine that performs a task but does not return a value to the calling code. It is used for actions or commands.
FunctionA type of subroutine that performs a task and returns a value to the calling code. It is used for calculations or data retrieval.
CallThe act of executing a subroutine or function from another part of the program. This transfers control to the subroutine.
Return ValueThe data that a function sends back to the part of the program that called it. Procedures do not have return values.

Watch Out for These Misconceptions

Common MisconceptionProcedures and functions work the same way.

What to Teach Instead

Procedures execute tasks without returning values, while functions must return a result. Active tracing exercises in pairs help students follow code paths step-by-step, clarifying execution differences through visual flowcharts and test runs.

Common MisconceptionSubroutines make code slower or unnecessary for small programs.

What to Teach Instead

Modular code runs at the same speed and builds good habits early. Hands-on refactoring in small groups demonstrates faster debugging and easier changes, as edits stay local to one subroutine.

Common MisconceptionFunctions can only return numbers.

What to Teach Instead

Functions return any data type, like strings or lists. Collaborative coding challenges let students experiment with varied returns, reinforcing flexibility through immediate error feedback and peer examples.

Active Learning Ideas

See all activities

Real-World Connections

  • Software developers at game studios like Rockstar Games use functions extensively to manage complex game logic, such as character movement, AI behavior, and rendering graphics. Each function handles a specific task, making the massive codebase manageable.
  • Web developers building e-commerce sites like Amazon use subroutines to organize common tasks like validating user input, processing payments, or displaying product information. This modular approach ensures consistency and speeds up development.
  • Data scientists analyzing large datasets for companies like DeepMind employ functions to perform specific calculations, such as data cleaning, statistical analysis, or model training. This allows them to reuse complex analytical steps across different projects.

Assessment Ideas

Exit Ticket

Provide students with a short Python code snippet that uses a procedure and a function. Ask them to identify which is which, explain why, and describe what the return value (if any) represents.

Quick Check

Present students with a simple problem (e.g., calculating the area of a rectangle and printing the result). Ask them to write down the pseudocode for two subroutines: one to calculate the area (a function) and one to display the result (a procedure).

Discussion Prompt

Pose the question: 'Imagine you are building a program to manage a library. What are three distinct tasks you could create as separate subroutines, and would each be a procedure or a function? Justify your choices.'

Frequently Asked Questions

What is the key difference between procedures and functions?
Procedures perform actions, such as printing messages or looping through data, without sending a value back to the caller. Functions compute something specific and return it, enabling reuse in expressions like result = calculate_total(scores). Teaching this through live code examples in Python or pseudocode helps students grasp how return statements control flow and data sharing across program parts.
Why use subroutines to improve code readability?
Subroutines hide implementation details, letting readers focus on high-level logic. A main program calls draw_rectangle() instead of 20 lines of repeated code. Students justify this in GCSE tasks by comparing modular and linear versions, noting shorter, clearer structures that reduce cognitive load during review or teamwork.
How can active learning help students master subroutines and functions?
Active approaches like pair programming and live refactoring let students build programs incrementally, test calls immediately, and observe benefits firsthand. Debugging a broken subroutine in small groups reveals why modularity saves time, while relay traces build execution understanding. These methods turn theory into practice, boosting retention and problem-solving confidence over passive lectures.
How do you assess understanding of program design with subroutines?
Use tasks where students decompose a problem into subtasks, sketch subroutine structures with parameters and returns, then implement and test. Rubrics score justification of modularity, correct differentiation of procedures/functions, and error-free execution. Peer reviews add depth, as students explain choices in their designs.
Subroutines and Functions | Year 10 Computing Lesson Plan | Flip Education