Revise Computingrevisecomputing.co.uk
At a glanceFeaturesStudentsPricingHow it worksFree GCSE notesExam dates
At a glanceFeaturesStudentsPricingHow it worksFree GCSE notesExam dates

Knowledge organisers / Subprograms

Why subprograms

All topicsPractise exam questions
Knowledge organiser

Subprograms

301.12a

Reasons to split code.

What you need to know

Subprograms (functions and procedures) break code into reusable, named blocks. This makes programs shorter, easier to read, test, and maintain.

Key points

  • Avoid repeating the same code — write it once, call it many times
  • Each subprogram does one clear job
  • Easier to test each part independently
  • Makes the main program shorter and more readable

Code examples

Why use subprograms
python
# Without subprogram: repeated code
print("="*20)
print("Welcome")
print("="*20)

# With subprogram: reusable
def show_header():
    print("="*20)
    print("Welcome")
    print("="*20)

show_header()