You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
This lesson provides an overview of the major programming paradigms — distinct approaches to structuring and writing programs. Understanding paradigms is essential for A-Level Computer Science, as you need to compare their characteristics, strengths, and appropriate use cases.
A programming paradigm is a fundamental style or approach to programming that provides a framework for thinking about and structuring code. Different paradigms suit different types of problems, and most modern languages support multiple paradigms.
| Paradigm | Core Idea |
|---|---|
| Procedural | Programs are sequences of instructions organised into procedures. |
| Object-Oriented (OOP) | Programs are organised around objects that combine data and behaviour. |
| Functional | Programs are built from pure functions without side effects. |
| Declarative | Programs describe what to compute, not how to compute it. |
| Event-driven | Programs respond to events such as user actions or messages. |
Procedural programming organises code into procedures (also called functions or subroutines) that operate on data. The program is a sequence of instructions that execute from top to bottom, with control structures (selection, iteration) and procedure calls.
PROCEDURE greet(name: STRING)
OUTPUT "Hello, " + name
END PROCEDURE
FUNCTION add(a: INTEGER, b: INTEGER) RETURNS INTEGER
RETURN a + b
END FUNCTION
greet("Alice")
result = add(3, 5)
OUTPUT result
def greet(name: str):
print(f"Hello, {name}")
def add(a: int, b: int) -> int:
return a + b
greet("Alice")
result = add(3, 5)
print(result)
OOP has been covered extensively in earlier lessons. In summary, OOP organises programs around objects — instances of classes that encapsulate both data (attributes) and behaviour (methods).
Functional programming treats computation as the evaluation of mathematical functions. It avoids mutable state and side effects, making programs more predictable and easier to reason about.
| Concept | Description |
|---|---|
| Pure functions | Functions that always return the same output for the same input and have no side effects. |
| Immutability | Data cannot be changed after creation. New data structures are created instead. |
| First-class functions | Functions can be assigned to variables, passed as arguments, and returned from other functions. |
| Higher-order functions | Functions that take other functions as arguments or return functions. |
| Recursion | Used instead of loops for iteration. |
| No side effects | Functions do not modify external state (no global variables, no I/O). |
# Pure function: no side effects, same input always gives same output
def add(a: int, b: int) -> int:
return a + b
# Impure function: modifies external state (side effect)
total = 0
def add_to_total(value: int):
global total
total += value # Side effect: changes global variable
# map: apply a function to every element
numbers = [1, 2, 3, 4, 5]
squared = list(map(lambda x: x ** 2, numbers))
# [1, 4, 9, 16, 25]
# filter: keep elements that satisfy a condition
evens = list(filter(lambda x: x % 2 == 0, numbers))
# [2, 4]
# reduce: combine elements into a single value
from functools import reduce
total = reduce(lambda a, b: a + b, numbers)
# 15
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.