Revise Computing
Revision notesQuestionsFor schools
Log inStart revising free
Revision notesQuestionsFor schoolsLog in
GCSE Computer Science/Supplementary programming practice/Subprograms

Scope + parameters

301.12 Subprograms

Practise exam questions

Subprograms — Note 4 of 4

Local vs global.

What you need to know

Variables defined inside a function are local — they only exist inside that function. Parameters pass data into a function. Global variables exist outside all functions.

What to know

  • Local variable: created inside a function, dies when function ends
  • Global variable: created outside, accessible everywhere
  • Parameters: values passed into a function when called
  • Avoid using global variables — pass data via parameters instead

Code examples

Scope example
python
def double(n):      # n is a parameter (local)
    result = n * 2  # result is local
    return result

x = 5               # x is global
print(double(x))    # 10
# print(result)     # Error — result doesn't exist here
← Previous noteFunctions301.12 SubprogramsNext topic →Why test?301.13 Testing

Back to Subprograms

Specification notes for programming are in Paper 2.

Subprograms

Note 4 of 4

  1. 1Why subprograms
  2. 2Procedures
  3. 3Functions
  4. 4Scope + parameters
Topic overview

© 2026 Revise Computing · revisecomputing.co.uk

Privacy noticeTermsContact

Revise Computing is an independent revision resource. It is not affiliated with, or endorsed by, OCR (Oxford Cambridge and RSA Examinations).