Procedures and functions

About this lesson: Procedures and functions

In short

A subroutine is a named block of code. Calling it runs the block, then returns to where it was called.

Procedures and functions

What you'll explore

Subroutines: Jump in, run, jump back
A subroutine is a named block of code. Calling it runs the block, then returns to where it was called.
Functions return a value: A routine that answers
A function calculates and RETURNS a value; a procedure just does a job. Change the inputs.
Why use them?: Write once, use many times
Subroutines avoid repeated code, make programs easier to test and let teams split work.
Check yourself: Procedure or function?
A subroutine works out the VAT on a price and sends the result back.

Also in this lesson

  • Step by step
  • Watch out for these
  • More than the lesson
  • Stretch your brain
  • Try it yourself

Words to know

Subroutine
A named block of code that can be called.
Procedure
A subroutine that does not return a value.
Function
A subroutine that returns a value.
Call
Running a subroutine.
Return value
The value a function sends back.

Sources

  • Python documentation: defining functions
  • Raspberry Pi Foundation, Isaac Computer Science: subroutines
  • Computer History Museum: EDSAC and early subroutines
  • BBC Bitesize, GCSE Computer Science: subroutines

An interactive lesson with a live experiment: move the sliders, press the buttons and answer quick questions. 4 short steps and a 8-question quiz. Part of the Family plan. Written and checked by Shalo Lab. Last updated 11 November 2026.

Parameters, local and global variables →

All lessons in Term 1 · Computing · Age 15