Python is the most widely used programming language in UK GCSE Computer Science classrooms. This guide covers every Python skill assessed on AQA, OCR and Cambridge papers — with worked examples, exam technique tips and common mistakes to avoid.
Organised from foundation to higher-level topics. All of these can appear in Paper 2 / Component 2 on the written exam — you need to write and trace Python code from memory.
Key points
Worked example
name = input("Enter your name: ")
age = int(input("Enter your age: "))
print(f"Hello {name}, you are {age} years old.")
# Type conversion
price = float("9.99") # string → float
code = str(42) # int → string Key points
Worked example
score = int(input("Enter score: "))
if score >= 90:
grade = "A"
elif score >= 70:
grade = "B"
elif score >= 50:
grade = "C"
else:
grade = "Fail"
print(f"Grade: {grade}") Key points
Worked example
# FOR loop — count 1 to 5
for i in range(1, 6):
print(i)
# WHILE loop — keep asking until valid input
number = -1
while number < 0:
number = int(input("Enter a positive number: "))
print(f"You entered: {number}")
# Accumulator pattern
total = 0
for i in range(1, 11):
total += i
print(f"Sum 1-10: {total}") # 55 Key points
Worked example
def calculate_area(length, width):
area = length * width
return area
# Call the function
room_area = calculate_area(5, 3)
print(f"Area: {room_area} m²") # Area: 15 m²
# Function with validation
def is_valid_grade(grade):
return 0 <= grade <= 100
print(is_valid_grade(85)) # True
print(is_valid_grade(110)) # False Key points
Worked example
scores = [75, 88, 62, 91, 50]
# Access and modify
print(scores[0]) # 75 — first item
print(scores[-1]) # 50 — last item
scores.append(83) # Add 83 to end
# Find maximum without max()
highest = scores[0]
for score in scores:
if score > highest:
highest = score
print(f"Top score: {highest}") # 91
# Count items over 70
count = 0
for score in scores:
if score >= 70:
count += 1
print(f"{count} students passed") Key points
Worked example
word = "Computer"
print(len(word)) # 8
print(word[0]) # C
print(word[-1]) # r
print(word[0:4]) # Comp
print(word.upper()) # COMPUTER
print(word.lower()) # computer
# Reverse a string
reversed_word = word[::-1]
print(reversed_word) # retupmoC
# Check if palindrome
def is_palindrome(s):
s = s.lower()
return s == s[::-1]
print(is_palindrome("racecar")) # True Key points
Worked example
# Writing to a file
with open("scores.txt", "w") as f:
f.write("Alice,88\n")
f.write("Bob,74\n")
# Reading from a file
with open("scores.txt", "r") as f:
for line in f:
line = line.strip() # Remove newline
name, score = line.split(",")
print(f"{name}: {score}") Key points
Worked example
# Linear search
def linear_search(lst, target):
for i in range(len(lst)):
if lst[i] == target:
return i # Found at index i
return -1 # Not found
# Bubble sort
def bubble_sort(lst):
n = len(lst)
for pass_num in range(n - 1):
swapped = False
for j in range(n - 1 - pass_num):
if lst[j] > lst[j + 1]:
lst[j], lst[j + 1] = lst[j + 1], lst[j]
swapped = True
if not swapped: # Early termination
break
return lst
print(bubble_sort([5, 2, 8, 1, 9])) # [1, 2, 5, 8, 9] One-to-one Python tutoring sessions with an experienced Computer Science teacher. Work through the programming questions you find hardest — from basic loops to writing full algorithms — in a supportive online environment.
Python is not mandated by any exam board — AQA 8525, OCR J277 and Cambridge 0478 all accept any high-level language. However, Python is by far the most widely used language in UK schools for GCSE CS, and the question papers use a pseudocode that maps very closely to Python syntax. Most mark schemes accept Python code directly.
The most commonly assessed Python topics at GCSE are: variables and data types, input() and print(), IF/ELIF/ELSE selection, FOR and WHILE loops, functions and return values, lists and list operations, string manipulation (len, slicing, concatenation), file reading/writing, and simple algorithms such as searching and sorting.
Yes. The written paper is closed-book and you cannot run code. You must write correct or near-correct Python from memory. The most commonly needed syntax is: if/elif/else, for i in range(), while, def/return, print(), input(), int(), str(), len(), and list operations like .append() and indexing.
Python (or pseudocode) questions appear on Paper 2 / Component 2 for AQA, OCR and Cambridge. Typical question types: write a program to do X, trace through the given code and write what it outputs, identify and fix the bug in the program, extend or modify existing code.
Pseudocode is a human-readable representation of an algorithm using structured English and programming constructs, without the strict syntax rules of a real language. Each exam board has its own pseudocode style. Python is a real programming language you can run. In the exam, both are accepted — but stick to the style the question uses if it provides code, and use Python if you are more comfortable with it.