Skip to content » A Level Computer Science Home » Functions & Procedures

Functions & Procedures



A procedure is a named section of code that can be called(run) anywhere within a program.

All procedures have 2 parts:

The Definition

This is where the code section is separated from the rest of the code and given a name. Defining a procedure does nothing until the code is called.

def hello_world():
    print("Nice to meet you world")

The Call

We run a procedure by calling  it by its name.

hello_world() #This will run the hello_world() procedure.

You can call a function as many times as you like:

while True:
    hello_world() #This will keep running the function inifitely.




A function is similar to a procedure but with one key difference – it returns a value (or object) to the line where the function was called.

def gimme_five():
    return 5

You can choose to do whatever you like with the return value.

print(gimme_five()) #This will print out the number 5

x = gimme_five() #This will take the return value 5 and set x to be 5




Input Parameters





You can practice writing your own functions using these Python functions challenges.


Exam Questions

June 16 Paper 22 Questions 2,3