Decomposition and abstraction
Decomposition and abstraction are two of the four computational thinking pillars named in every UK GCSE Computer Science specification. Decomposition means breaking a bigger problem into smaller, manageable sub-problems; abstraction means hiding the irrelevant detail so you can reason about what matters. This unit shows how to apply both to Python code: turning a long procedural script into a set of small, well-named functions that each do one job. Perfect for classroom teaching, GCSE and A Level revision, and independent or home-schooled learners.
What you'll learn
- Recognise the four computational thinking pillars (decomposition, abstraction, pattern recognition, algorithms)
- Break a program into small single-purpose functions
- Use good function names to abstract 'how' behind a clear 'what'
- Pass data between functions with parameters and return values
- Recognise repeated patterns and factor them into helpers
UK GCSE topic coverage
- Computational thinking
- Decomposition in practice
- Planning subroutines
- Applied decomposition
- Function composition
- Applied processing pipelines
Worked example
Decomposing a program into three named functions
def get_score():
return int(input("Score? "))
def grade(score):
if score >= 70:
return "A"
if score >= 50:
return "B"
return "C"
def report():
s = get_score()
print("Grade:", grade(s))
report()Try a full unit free with a RunPy account
Sign up free and get the whole of Unit 1 (Input, Output and Variables) with checked tasks and instant feedback, plus a selection of the exam-style questions so you can practice on real GCSE-style content before upgrading.
Lessons in this unit
Full interactive lessons with checked tasks are available to signed-in RunPy users. Unit 1 and a selection of exam-style questions are free with a RunPy account.
- Why decomposition?
- Splitting a problem into functions
- Planning functions before coding
- Building a multi-function program
- Choosing and chaining functions
- Reusing helper functions in a string system
- Repeated data processing with multiple functions
Frequently asked questions
- What is decomposition in Computer Science?
- Breaking a large problem into smaller sub-problems that can be solved independently. In Python, this usually means writing several small functions instead of one long block.
- What is abstraction in Computer Science?
- Hiding irrelevant detail so you can focus on what matters. Naming a function grade(score) is an abstraction: callers don't need to know how the grade is computed, just what it returns.
- Is this required by GCSE?
- Yes. Every UK GCSE Computer Science specification lists decomposition and abstraction as computational thinking skills that pupils must demonstrate.