← Edexcel GCSE

Subroutines: Edexcel GCSE practice

Functions, procedures, parameters and scope. 12 questions in the style of the Edexcel GCSE exam.

Sample questions

What is the main difference between a function and a procedure?

  1. A function returns a value; a procedure does not
  2. A procedure can have parameters; a function cannot
  3. A function must print something
  4. There is no difference in Python

What does this program print?

def greet(name, times):
    for i in range(times):
        print("Hi " + name)

greet("Sam", 2)
greet("Jo", 1)

Which statement about local variables is true?

  1. They can be used anywhere in the program
  2. They only exist while the subroutine they are declared in is running
  3. They keep their value between calls
  4. They must be declared with the keyword global