AQA GCSE Computer Science (8525) · Paper 2 Desk Reference
Python & SQL Exam Cheat Sheet
Keep this quick-reference sheet beside your keyboard during revision. Contains every programming construct, string method, file operation, and SQL syntax rule tested in AQA Paper 2.
1. Data Types & Type Casting
AQA 3.1.1# Type Casting
age = int("16") # 16 (Integer)
price = float("19.99") # 19.99 (Real/Float)
text = str(42) # "42" (String)
flag = bool(1) # True (Boolean)
# User Input (Always cast numerical input!)
user_name = input("Enter name: ")
user_score = int(input("Enter score: "))
2. Arithmetic & Comparison
AQA 3.1.2# Odd/Even Test (Common 2-mark question)
if number % 2 == 0:
print("Even")
else:
print("Odd")
3. String Handling & Slicing
AQA 3.1.4word = "AQA COMPUTER"
len(word) → 12
word.lower() → "aqa computer"
word.upper() → "AQA COMPUTER"
word.find("COMP") → 4 (index of match)
# Slicing: [start:stop] (up to, NOT including stop)
word[0:3] → "AQA" (indices 0, 1, 2)
word[4:] → "COMPUTER" (from 4 to end)
word[-1] → "R" (last character)
4. Selection & Iteration Loops
AQA 3.1.3# Count-Controlled Loop (for)
for i in range(1, 6): # 1, 2, 3, 4, 5
print(i)
for i in range(10, 0, -2): # 10, 8, 6, 4, 2
print(i)
# Condition-Controlled Loop (while)
attempts = 0
while attempts < 3:
pin = input("Enter PIN: ")
if pin == "1234": break
attempts += 1
5. Lists & 2D Arrays (Matrices)
AQA 3.1.5# 1D List Operations
fruits = ["Apple", "Banana", "Cherry"]
fruits.append("Date") # Adds to end
fruits[1] = "Blueberry" # Updates Banana
len(fruits) → 4
# 2D Array: grid[row][column]
grid = [
[10, 20, 30], # row 0
[40, 50, 60] # row 1
]
val = grid[1][2] # Row 1, Col 2 → 60
# Nested Loop Traversal
for r in range(len(grid)):
for c in range(len(grid[r])):
print(grid[r][c])
6. File Handling (Read & Write)
AQA 3.1.6# Reading line by line until End-Of-File
my_file = open("scores.txt", "r")
line = my_file.readline().strip()
while line != "":
print(line)
line = my_file.readline().strip()
my_file.close() # Always close!
# Writing / Appending to file
my_file = open("log.txt", "w") # "w" overwrites, "a" appends
my_file.write("Exam Completed\n")
my_file.close()
7. AQA SQL Reference (Section B)
AQA 3.2.7-- Standard Query Structure
SELECT first_name, score, class
FROM students
WHERE score >= 70 AND class = '11C'
ORDER BY score DESC;
-- Wildcard Search & Logical Conditions
WHERE surname LIKE 'Sm%' -- Starts with 'Sm'
WHERE email LIKE '%@aqa.org' -- Ends with domain
WHERE grade <> 9 -- Not equal (<> or !=)
-- Aggregate Functions (if tested)
SELECT COUNT(*), AVG(score), MAX(score) FROM results;
⚠️ The 5 “Silly Mistakes” That Cost Marks in Paper 2
- •Forgetting colons: Every
def,if,for, andwhileline must end with a colon: - •Range off-by-one:
range(1, 5)only runs 4 times (1, 2, 3, 4). Stop value is excluded! - •Zero-based index: The first element of a string or list is
index 0, never 1. - •Closing files: You lose a mark if you open a file without writing
file.close()at the end. - •Single vs double equals:
=is for assignment (x = 5);==is for comparison (if x == 5:).
Want these printable sheets emailed to your inbox?
Get the full A4 print-ready PDF bundle delivered straight to your email: the Paper 2 Python & SQL Cheat Sheet, the Top 20 AQA Exam Trapdoors Guide, and the Official 8525 Revision Checklist.
Want in-browser Python & SQL practice that checks your code as you type?
UpperGrades lessons include built-in coding challenges with automated AQA mark scheme verification. No software to install — code directly on any browser.
One price for up to 3 children · Cancel anytime
