GCSE Computer Science AQA Paper 2 Study
Guide
Section B Focus: Programming Skills
Table of Contents
1. Paper 2 Structure Overview
2. Section B - Programming Focus
3. Pseudocode to Python Translation Guide
4. Essential Programming Constructs
5. Common Algorithm Patterns
6. Data Structures
7. Trace Tables & Code Execution
8. Exam Technique Tips
9. Common Errors to Avoid
10. Practice Strategies
Paper 2 Structure Overview
Paper 2 tests your practical programming skills. The paper consists of:
• Section A: Short questions on various programming concepts (25%)
• Section B: Longer programming questions requiring code writing (75%)
Key information:
• Duration: 2 hours
• Total marks: 80
• Worth 50% of your GCSE
• On-screen examination
Section B - Programming Focus
Section B focuses on your ability to:
1. Write code to solve problems
2. Interpret code to determine outputs
3. Modify code to meet new requirements
4. Correct errors in given code
5. Convert between pseudocode and Python
You'll need to demonstrate understanding of:
• Sequence, selection, and iteration
• Variables and constants
• Data types and structures
• Input/output operations
• Subroutines (functions/procedures)
• File handling
• Algorithm design and efficiency
Pseudocode to Python Translation Guide
Basic Syntax Comparison
Concept Pseudocode Python
Output OUTPUT "Hello" print("Hello")
Input INPUT name name = input()
Assignment total ← 0 total = 0
Comments // This is a comment # This is a comment
Selection (If Statements)
Pseudocode:
IF age >= 18 THEN
OUTPUT "You can vote"
ELSE
OUTPUT "Too young to vote"
ENDIF
Python:
if age >= 18:
print("You can vote")
else:
print("Too young to vote")
Multiple Conditions
Pseudocode:
IF score >= 90 THEN
OUTPUT "Grade A"
ELSE IF score >= 70 THEN
OUTPUT "Grade B"
ELSE IF score >= 50 THEN
OUTPUT "Grade C"
ELSE
OUTPUT "Fail"
ENDIF
Python:
if score >= 90:
print("Grade A")
elif score >= 70:
print("Grade B")
elif score >= 50:
print("Grade C")
else:
print("Fail")
Iteration - For Loops
Pseudocode:
FOR i ← 1 TO 5
OUTPUT i
NEXT i
Python:
for i in range(1, 6): # Note: range(1, 6) gives 1, 2, 3, 4, 5
print(i)
Iteration - While Loops
Pseudocode:
counter ← 1
WHILE counter <= 5 DO
OUTPUT counter
counter ← counter + 1
ENDWHILE
Python:
counter = 1
while counter <= 5:
print(counter)
counter = counter + 1 # or counter += 1
Iteration - Repeat Until
Pseudocode:
counter ← 1
REPEAT
OUTPUT counter
counter ← counter + 1
UNTIL counter > 5
Python:
counter = 1
while True:
print(counter)
counter = counter + 1
if counter > 5:
break
OR
counter = 1
while not (counter > 5):
print(counter)
counter = counter + 1
Arrays/Lists
Pseudocode:
DECLARE numbers : ARRAY[1:5] OF INTEGER
numbers[1] ← 10
numbers[2] ← 20
OUTPUT numbers[1]
Python:
numbers = [0] * 5 # Creates [0, 0, 0, 0, 0]
# Python uses 0-based indexing!
numbers[0] = 10 # First element
numbers[1] = 20 # Second element
print(numbers[0])
Functions/Procedures
Pseudocode (Procedure):
PROCEDURE greet(name)
OUTPUT "Hello, " + name
ENDPROCEDURE
greet("Alex")
Python:
def greet(name):
print("Hello, " + name)
greet("Alex")
Pseudocode (Function):
FUNCTION square(number)
RETURN number * number
ENDFUNCTION
result ← square(4)
OUTPUT result
Python:
def square(number):
return number * number
result = square(4)
print(result)
Essential Programming Constructs
1. Variables and Constants
Python:
# Variables
name = "Alex" # String
age = 16 # Integer
height = 1.75 # Float
is_student = True # Boolean
# Constants (by convention, use uppercase)
PI = 3.14159
MAX_STUDENTS = 30
Key points:
• Python automatically determines data types
• Variable names should be descriptive
• Cannot use reserved words (if, for, while, etc.)
2. String Operations
Python:
name = "Computer Science"
# Length
length = len(name) # 16
# Accessing characters (zero-indexed)
first_char = name[0] # 'C'
# Slicing
substr = name[0:8] # 'Computer'
# Concatenation
greeting = "Hello, " + name # 'Hello, Computer Science'
# String methods
lowercase = name.lower() # 'computer science'
uppercase = name.upper() # 'COMPUTER SCIENCE'
3. Mathematical Operations
Python:
a = 10
b = 3
addition = a + b # 13
subtraction = a - b # 7
multiplication = a * b # 30
division = a / b # 3.3333... (float)
integer_division = a // b # 3 (integer)
remainder = a % b # 1
power = a ** b # 1000 (10^3)
4. Logical Operators
Python:
x = 5
y = 10
# Comparison operators
is_equal = x == y # False
not_equal = x != y # True
greater_than = x > y # False
less_than = x < y # True
greater_equal = x >= y # False
less_equal = x <= y # True
# Logical operators
and_result = (x > 0) and (y > 0) # True
or_result = (x > 10) or (y > 0) # True
not_result = not (x > 0) # False
Common Algorithm Patterns
1. Input Validation
Python:
# Validate numeric input
valid_input = False
while not valid_input:
user_input = input("Enter a number between 1-10: ")
if user_input.isdigit():
number = int(user_input)
if 1 <= number <= 10:
valid_input = True
else:
print("Number must be between 1 and 10")
else:
print("You must enter a number")
2. Finding Maximum Value
Python:
numbers = [45, 22, 67, 34, 18]
max_value = numbers[0] # Assume first is largest
for num in numbers:
if num > max_value:
max_value = num
print(max_value) # 67
3. Counting Occurrences
Python:
text = "hello world"
target = "l"
count = 0
for char in text:
if char == target:
count += 1
print(count) # 3
4. Linear Search
Python:
def linear_search(arr, target):
for i in range(len(arr)):
if arr[i] == target:
return i # Return position if found
return -1 # Return -1 if not found
numbers = [5, 8, 12, 16, 23]
position = linear_search(numbers, 12)
print(position) # 2
5. Binary Search (for sorted lists)
Python:
def binary_search(arr, target):
low = 0
high = len(arr) - 1
while low <= high:
mid = (low + high) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
low = mid + 1
else:
high = mid - 1
return -1 # Not found
sorted_numbers = [2, 5, 8, 12, 16, 23, 38, 56, 72, 91]
position = binary_search(sorted_numbers, 23)
print(position) # 5
6. Bubble Sort
Python:
def bubble_sort(arr):
n = len(arr)
for i in range(n):
for j in range(0, n-i-1):
if arr[j] > arr[j+1]:
# Swap elements
arr[j], arr[j+1] = arr[j+1], arr[j]
return arr
numbers = [64, 34, 25, 12, 22, 11, 90]
sorted_numbers = bubble_sort(numbers)
print(sorted_numbers) # [11, 12, 22, 25, 34, 64, 90]
7. Total and Average
Python:
numbers = [10, 20, 30, 40, 50]
total = 0
for num in numbers:
total += num
average = total / len(numbers)
print(f"Total: {total}, Average: {average}") # Total: 150, Average: 30.0
Data Structures
1. Lists (Arrays)
Python:
# Creating lists
empty_list = []
numbers = [10, 20, 30, 40, 50]
mixed = [1, "hello", True, 3.14]
# Accessing elements (zero-indexed)
first = numbers[0] # 10
last = numbers[-1] # 50
# Modifying elements
numbers[1] = 25 # [10, 25, 30, 40, 50]
# List operations
length = len(numbers) # 5
numbers.append(60) # Add to end: [10, 25, 30, 40, 50, 60]
numbers.insert(1, 15) # Insert at position: [10, 15, 25, 30, 40, 50, 60]
numbers.remove(30) # Remove by value: [10, 15, 25, 40, 50, 60]
popped = numbers.pop() # Remove & return last: 60, list becomes [10, 15, 25,
40, 50]
numbers.sort() # Sort in place: [10, 15, 25, 40, 50]
2. Two-dimensional Lists (2D Arrays)
Python:
# Creating a 2D list (3x3 grid)
grid = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
# Accessing elements (row, column)
element = grid[1][2] # row 1, column 2: value 6
# Iterating through a 2D list
for row in grid:
for item in row:
print(item, end=" ")
print() # New line after each row
3. Dictionaries (Key-Value Pairs)
Python:
# Creating a dictionary
student = {
"name": "Alex",
"age": 16,
"grades": [85, 90, 78]
}
# Accessing values
name = student["name"] # "Alex"
# Alternative safer method
age = student.get("age", 0) # 16 (returns 0 if key doesn't exist)
# Adding/modifying entries
student["school"] = "High School"
student["age"] = 17
# Checking if key exists
has_email = "email" in student # False
# Iterating through a dictionary
for key in student:
print(f"{key}: {student[key]}")
# Get all keys or values
keys = student.keys()
values = student.values()
Trace Tables & Code Execution
Understanding Code with Trace Tables
A trace table tracks the values of variables as code executes line by line.
Example Code:
total = 0
for i in range(1, 5):
if i % 2 == 0:
total += i * 2
else:
total += i
print(total)
Trace Table:
Line i i % 2 == 0 Action total
1 - - total = 0 0
2-5 1 False total += 1 1
2-5 2 True total += 2*2 5
2-5 3 False total += 3 8
2-5 4 True total += 4*2 16
6 - - print(16) 16
Tips for Creating Trace Tables
1. Identify all variables that change during execution
2. Create columns for these variables and code execution
3. Track each line of code and update variables accordingly
4. Pay special attention to loops and conditionals
5. Always double-check your calculations
Exam Technique Tips
Understanding Code Questions
1. Read carefully - Understand exactly what the question is asking
2. Annotate the code - Write notes to explain what each part does
3. Use trace tables - Track variables for complex code
4. Look for patterns - Identify familiar algorithms or constructs
5. Consider edge cases - What happens with special inputs?
Writing Code Questions
1. Plan before coding - Outline your algorithm in plain English first
2. Use proper indentation - Even in pseudocode, clear structure helps
3. Include comments - Explain your thinking
4. Check initialization - Ensure variables are set before use
5. Test your solution - Mentally trace through with example inputs
6. Be consistent - Stick to one style of naming and syntax
Python vs. Pseudocode Strategy
• If comfortable with Python, write in Python
• If unsure about syntax, use pseudocode
• You can mix both in the same answer if needed
• Focus on showing your algorithm logic over perfect syntax
Time Management
• Read the entire question before starting
• Allocate time based on marks (approximately 1 minute per mark)
• For complex questions, write a brief plan first
• If stuck, move on and return later
• Leave a few minutes to review your answers
Common Errors to Avoid
1. Syntax Errors
• Forgetting colons after if, else, for, while, etc.
• Incorrect indentation in Python
• Mismatched parentheses or brackets
• Mixing single and double equals (= vs ==)
2. Logical Errors
• Off-by-one errors in loops
• Incorrect loop conditions (infinite loops)
• Incorrect logical operators (and, or, not)
• Missing or incorrect return statements
3. Data Type Errors
• Forgetting to convert input strings to numbers
• Trying to perform mathematical operations on strings
• Indexing beyond list boundaries
• Using a variable before initializing it
4. Algorithm Errors
• Incorrect initialization of counters or accumulators
• Not handling edge cases (empty lists, zero values)
• Incorrect comparison operators
• Incorrect ordering of operations
5. Common Misunderstandings
• Python lists are zero-indexed (first element is at position 0)
• Integer division (//) vs. float division (/)
• String concatenation requires explicit conversion of numbers
• Variables inside functions are local by default
Practice Strategies
1. Code Translation Exercises
• Convert pseudocode examples to Python
• Convert Python code to pseudocode
• Compare solutions to see differences in syntax
2. Trace Table Practice
• Create trace tables for progressively more complex code
• Predict outputs before running code
• Check your predictions by running the code
3. Bug-Fixing Practice
• Identify and fix errors in broken code snippets
• Common bugs include:
o Off-by-one errors
o Incorrect loop conditions
o Missing initializations
o Logic errors in if statements
4. Algorithm Implementation
Practice implementing these key algorithms:
• Linear search
• Binary search
• Bubble sort
• Selection sort
• Count occurrences
• Find minimum/maximum
• Calculate average/total
5. Past Paper Practice
• Time yourself when completing past paper questions
• Review mark schemes to understand expected answers
• Focus on areas where you lose marks
6. Memory Aids
Remember with "PIFW":
• Print = print() in Python, OUTPUT in pseudocode
• Input = input() in Python, INPUT in pseudocode
• For loops = for i in range(): in Python, FOR i ← start TO end in pseudocode
• While loops = while condition: in Python, WHILE condition DO in pseudocode
Programming Checklist:
• Did I initialize all variables?
• Are my conditions correct?
• Have I used the correct comparison operators?
• Are my loops processing the correct range of values?
• Have I handled all possible inputs?
Final Tips for Success
1. Break down complex problems into smaller, manageable steps
2. Use the PRIMM approach:
o Predict what code will do
o Run code to check your prediction
o Investigate how it works
o Modify the code to change its behavior
o Make your own similar code
3. Practice regularly with small coding problems
4. Explain code to others (or pretend to) to solidify understanding
5. Learn from mistakes in practice questions
6. Be methodical in exam questions - take time to understand before answering
7. Show your working - even partial solutions earn marks
8. Keep syntax reference sheets handy during revision
Remember: Understanding concepts is more important than memorizing syntax. If you
understand the logic, you can write the solution in either Python or pseudocode.
Good luck with your AQA Computer Science GCSE exam!