Edexcel 1CP2 1.1.2: Benefits of subprograms
The free BugBot lesson that teach this point, a robot to try it on, and the past-paper questions that test it.
What it covers
You have been calling functions since lesson F1.3: print, forward, distance. Now you write your own. A function is a named block of code you can run whenever you like, as often as you like, by calling its name. Exams call it a subprogram.
- Defining a function
- Define first, then call
- What happens when a function is called
- A function can call other functions
- Why write functions?
Or do it in the simulator, with tasks that mark themselves
Lessons that teach it
- F4.1 Writing functions Functions and structured code
def, calling, and why subprograms help.
Try it on a robot
The task from F4.1 Writing functions, running here. Change the program and press Run.
Past paper questions on this
Real exam questions that test this, each worked through with a program you can run.
- AQA 8525 June 2024 Paper 1, Question 14: Local variables, and a subroutine that counts busy days and returns the count 7 marks
- AQA 8525 June 2022 Paper 1, Question 14.2: Write a subroutine that counts the asterisks on a bingo ticket 8 marks
- AQA 8525 Sample Paper 1, Question 9: Draw a robot's path through a grid from Forward, TurnLeft and ObjectAhead 6 marks
- OCR J277 June 2025 Paper 2, Question 6(c): Write a function that returns a ticket price, then call it 6 marks
- OCR J277 June 2023 Paper 2, Question 6(e): A procedure with two parameters that writes to a text file 6 marks
- OCR J277 June 2022 Paper 2, Question 5(c): Write a function that returns a price, then call it 7 marks
- Edexcel 1CP2 June 2025 Paper 2, Question 6: Validate keys with a check digit and signal readings, with a subprogram 15 marks
- Edexcel 1CP2 June 2023 Paper 2, Question 5: A user ID: local and global names, a procedure, lower(), isdigit() and ord() 15 marks
The specification is Edexcel's own document; this page says which of our lessons teach point 1.1.2 and is not endorsed by the board.