Year 10 (ages 14–15, Grade 9 in the US) · Computing · GCSE programming · Lesson 9
Subroutines: functions and procedures
Writing subroutines in Python with def: procedures that carry out a task, functions that return a value, parameters and arguments, and why subroutines make programs easier to write, test and maintain.
Exam boards: this lesson matches the AQA and Pearson Edexcel GCSE computing courses. Check which course your school follows.

8-minute video lesson
Teaching, worked examples and 20 practice questions solved step by step.
Watch free for a monthWhat your child will learn
- Define and call a subroutine
- Use parameters and arguments
- Distinguish functions and procedures
- Explain the benefits of subroutines
The method
- def name(parameters): defines a subroutine.
- Call it by name with arguments.
- A function returns a value; a procedure does not.
- Benefits: reuse, testing, readability, teamwork.
Key words: subroutine, function, procedure, parameter, return.
Worked examples
Worked examples from the lesson, with every step.
Question 1
What does this output? c:def double(n): c: return n * 2 c:print(double(7) + 1)
- Step 1: double(7) returns 14
- Step 2: 14 + 1 = 15
Answer: 15
Question 2
Identify the parameters and arguments: c:def add(a, b): c: return a + b c:total = add(5, 9)
- Step 1: a, b
- Step 2: 5, 9
Answer: parameters a, b; arguments 5, 9
Question 3
Function or procedure? A subroutine that prints a menu.
- Step 1: Does it return a value?
- Step 2: No — it only prints.
Answer: procedure