AQA GCSE Computer Science: Programming and Boolean Logic
AQA GCSE Computer Science: Programming and Boolean Logic
Programming is the core of AQA GCSE Computer Science. Paper 1 is built around your ability to read, write, trace, and debug code -- and the programming concepts you learn also underpin the computational thinking that examiners test across both papers. Boolean logic, meanwhile, connects your understanding of conditions in code to the hardware-level logic gates that drive digital systems.
This guide covers every programming topic in the AQA specification, from the basics of variables and data types through to file handling and subroutines, followed by a thorough treatment of Boolean logic. If you can master these topics, you will be well prepared for the most challenging questions on Paper 1.
Variables, Constants, and Data Types
Variables and Constants
A variable is a named location in memory whose value can change while a program runs. In AQA pseudo-code, assignment uses an arrow:
score <- 0
name <- "Alex"
A constant is a named value that is set once and does not change during execution. Instead of writing 3.14159 every time you need pi, you define a constant:
CONSTANT PI <- 3.14159
If you ever need to update the value, you only change it in one place -- reducing the risk of errors and making your intent clear.
Data Types
AQA expects you to know five fundamental data types:
- Integer -- a whole number, positive or negative (e.g., 7, -3, 0). Used for counting and indexing.
- Real (also called float) -- a number with a decimal point (e.g., 3.14, -0.5). Used for measurements and calculations involving division.
- Boolean -- either
TrueorFalse. Used for flags, conditions, and binary states. - Character -- a single letter, digit, or symbol (e.g., 'A', '7', '#'). Each character maps to a numeric code in ASCII.
- String -- a sequence of characters (e.g., "Hello", "GCSE2026"). Used for text, names, and messages.
Understanding data types matters because operations behave differently depending on the type. Adding two integers gives an integer; adding two strings concatenates them. Mixing types without converting can cause errors.
Operators
Arithmetic Operators
These perform mathematical calculations:
+addition-subtraction*multiplication/real division (returns a decimal result)DIVinteger division (returns the whole number quotient, discarding the remainder)MODmodulus (returns the remainder after integer division)
DIV and MOD appear constantly in exam questions. For example, 17 DIV 5 gives 3 and 17 MOD 5 gives 2. A common use of MOD is checking whether a number is even: if n MOD 2 = 0, the number is even.
Comparison Operators
These compare two values and return a Boolean result:
=equal to!=not equal to<less than>greater than<=less than or equal to>=greater than or equal to
Comparison operators are used inside conditions for selection and iteration. Getting them wrong -- for example, using < when you mean <= -- is one of the most common sources of off-by-one errors.
Boolean Operators
Boolean operators combine or modify conditions:
- AND -- returns True only if both conditions are True
- OR -- returns True if at least one condition is True
- NOT -- inverts a Boolean value (True becomes False, False becomes True)
You can combine these to build complex conditions:
IF age >= 18 AND hasTicket = True THEN
OUTPUT "Entry allowed"
ENDIF
Selection
Selection allows your program to take different paths depending on whether a condition is True or False.
IF / ELSE / ELSEIF
The basic structure in AQA pseudo-code:
IF condition THEN
statements
ENDIF
Adding an alternative path:
IF score >= 50 THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
ENDIF
When you need to check multiple conditions in sequence, use ELSEIF:
IF score >= 70 THEN
OUTPUT "Distinction"
ELSEIF score >= 50 THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
ENDIF
Conditions are checked top to bottom. As soon as one is True, its block executes and the rest are skipped -- so place the most restrictive condition first.
Nested Selection
You can place one IF statement inside another when a decision depends on the outcome of a previous decision:
IF age >= 18 THEN
IF hasID = True THEN
OUTPUT "Entry granted"
ELSE
OUTPUT "ID required"
ENDIF
ELSE
OUTPUT "Too young"
ENDIF
Keep nesting to two or three levels in the exam and use clear indentation so the examiner can follow your logic.
Iteration
Iteration means repeating a block of code. AQA requires you to know three types of loop, each suited to different situations.
FOR Loops (Count-Controlled)
A FOR loop repeats a fixed number of times. You know in advance how many iterations are needed:
FOR i <- 1 TO 5
OUTPUT i
ENDFOR
This outputs 1, 2, 3, 4, 5. The loop variable i increments automatically. FOR loops are ideal when iterating through a known range, such as processing each element in an array.
WHILE Loops (Condition-Controlled, Pre-Check)
A WHILE loop repeats as long as a condition remains True. The condition is checked before each iteration, so it is possible for the loop body to execute zero times:
password <- USERINPUT
WHILE password != "secret123"
OUTPUT "Incorrect. Try again."
password <- USERINPUT
ENDWHILE
WHILE loops are used when you do not know in advance how many iterations are needed -- for example, when waiting for valid user input.
REPEAT-UNTIL Loops (Condition-Controlled, Post-Check)
A REPEAT-UNTIL loop executes the body first and then checks the condition. This guarantees at least one execution:
REPEAT
OUTPUT "Enter a number greater than 0"
num <- USERINPUT
UNTIL num > 0
The key difference: REPEAT-UNTIL always executes at least once, whereas a WHILE loop might not execute at all. Examiners frequently test this distinction.
Nested Iteration
Loops can be placed inside other loops -- essential for working with two-dimensional data or generating combinations:
FOR row <- 1 TO 3
FOR col <- 1 TO 4
OUTPUT row * col
ENDFOR
ENDFOR
The inner loop completes all its iterations for each single iteration of the outer loop, so OUTPUT executes 3 x 4 = 12 times. When tracing nested loops, complete the inner loop fully before moving to the next outer iteration.
Subroutines: Functions and Procedures
A subroutine is a named block of code that performs a specific task. It can be called from elsewhere in the program, allowing you to reuse code and break problems into manageable parts.
Procedures vs Functions
- A procedure performs a task but does not return a value.
- A function performs a task and returns a value to the point where it was called.
In AQA pseudo-code:
SUBROUTINE greet(name)
OUTPUT "Hello, " + name
ENDSUBROUTINE
SUBROUTINE calculateArea(length, width)
area <- length * width
RETURN area
ENDSUBROUTINE
The first subroutine is a procedure (it outputs something but does not return a value). The second is a function (it returns the calculated area).
Parameters and Return Values
Parameters are the values passed into a subroutine when it is called. They allow the subroutine to work with different data each time:
result <- calculateArea(5, 3)
OUTPUT result
Here, 5 and 3 are arguments passed to the parameters length and width. The function returns 15, which is stored in result.
Why Modular Programming Matters
Breaking a program into subroutines -- known as modular programming -- has several important benefits:
- Reusability. A subroutine can be called multiple times from different parts of the program without rewriting the code.
- Readability. A program built from well-named subroutines is easier to understand.
calculateArea(5, 3)is clearer than a block of inline calculation. - Testing. Each subroutine can be tested independently, making it easier to find and fix bugs.
- Maintenance. If the logic needs to change, you update it in one place rather than everywhere the code appears.
- Teamwork. Different programmers can work on different subroutines simultaneously.
Examiners often ask why programmers use subroutines. Make sure you can explain these benefits with specific examples rather than vague generalities.
String Handling
Strings are sequences of characters, and AQA expects you to manipulate them using built-in operations.
Key String Operations
-
Concatenation -- joining strings together using
+:fullName <- firstName + " " + lastName -
Length -- finding the number of characters in a string:
LEN("Hello")returns5 -
Substring -- extracting part of a string:
SUBSTRING(0, 3, "Computer")returns"Com"(starting at position 0, extracting 3 characters) -
Converting case --
UPPER("hello")returns"HELLO"andLOWER("HELLO")returns"hello". -
ASCII values -- each character has a corresponding ASCII code ('A' is 65, 'a' is 97, '0' is 48). Converting between characters and their codes is useful for encryption and validation:
CHAR_TO_CODE('A')returns65, andCODE_TO_CHAR(65)returns'A'.
Practical Applications
String handling is commonly tested through questions on:
- Input validation (checking that a string meets certain criteria, such as minimum length or containing only letters)
- Simple encryption (shifting characters by their ASCII values)
- Formatting output (building messages from multiple pieces of data)
Arrays and Lists
An array is a data structure that stores multiple values of the same type under a single name. Each value is accessed using an index.
Declaring and Accessing Arrays
In AQA pseudo-code, arrays are indexed from 0:
names <- ["Alice", "Bob", "Charlie", "Diana"]
OUTPUT names[0]
This outputs "Alice". The element at index 1 is "Bob", and so on.
You can assign new values to specific positions:
names[2] <- "Chris"
Iterating Through Arrays
A FOR loop is the natural way to process every element in an array:
FOR i <- 0 TO LEN(names) - 1
OUTPUT names[i]
ENDFOR
The loop runs from 0 to LEN(names) - 1 because an array of 4 elements has indices 0, 1, 2, 3. Using LEN(names) as the upper bound would attempt to access a non-existent element -- a common exam error.
Common Array Tasks
Examiners frequently ask you to write algorithms that:
- Search for a specific value in an array (linear search)
- Find the largest or smallest value
- Count how many elements meet a condition
- Sum or average the values in an array
For example, finding the maximum value:
max <- numbers[0]
FOR i <- 1 TO LEN(numbers) - 1
IF numbers[i] > max THEN
max <- numbers[i]
ENDIF
ENDFOR
OUTPUT max
File Handling
File handling allows your program to read data from and write data to text files so that information persists after the program ends.
Writing to a File
myFile <- OPEN("results.txt")
WRITELINE(myFile, "Score: 85")
WRITELINE(myFile, "Grade: A")
CLOSE(myFile)
Reading from a File
myFile <- OPEN("results.txt")
WHILE NOT ENDOFFILE(myFile)
line <- READLINE(myFile)
OUTPUT line
ENDWHILE
CLOSE(myFile)
Key Points
- Always close a file after you have finished reading from or writing to it. Failing to close a file can result in data loss or corruption.
- ENDOFFILE checks whether you have reached the end of the file. This is used with a WHILE loop to read all lines without knowing in advance how many there are.
- File handling questions in the exam often combine reading from a file with processing the data -- for example, reading a list of scores and calculating the average.
Boolean Logic
Boolean logic is the mathematical foundation of how computers make decisions. Every condition in your code and every logic gate in a processor relies on it.
Truth Tables
A truth table shows the output of a Boolean expression for every possible combination of inputs. For two inputs (A and B), there are four combinations. For three inputs, there are eight.
AND Truth Table:
| A | B | A AND B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
OR Truth Table:
| A | B | A OR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
NOT Truth Table:
| A | NOT A |
|---|---|
| 0 | 1 |
| 1 | 0 |
For more complex expressions, add intermediate columns. For example, A AND (NOT B):
| A | B | NOT B | A AND (NOT B) |
|---|---|---|---|
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 |
Always include intermediate columns in the exam -- they show your working and earn method marks even if your final answer contains an error.
Logic Gates
Logic gates are physical components that implement Boolean operations in circuits. You need to recognise three gates:
- AND gate -- output is 1 only when both inputs are 1
- OR gate -- output is 1 when at least one input is 1
- NOT gate -- output is the inverse of the input (also called an inverter)
When tracing a logic gate diagram, work left to right. Calculate the output of each gate in sequence and write intermediate values on the diagram to keep track.
Boolean Expressions
Boolean expressions combine variables and operators into logical statements. In AQA notation:
- AND can be written as a dot (.) or by placing variables together (AB)
- OR is written as a plus (+)
- NOT is shown with a bar over the variable or as a prefix
For example, the expression A AND (B OR NOT C) can be evaluated step by step:
- Calculate
NOT C - Calculate
B OR NOT C - Calculate
A AND (B OR NOT C)
Exam questions may ask you to write the Boolean expression for a given truth table, or to complete a truth table for a given expression. Both require systematic, careful working.
Writing Clean Code in the Exam
Clean code is easier to debug and easier for the examiner to follow -- both of which earn you more marks.
Use Meaningful Variable Names
Use names that describe what the variable stores -- totalScore, userInput, maxTemperature -- rather than x, y, z. This makes your code self-documenting.
Indent Consistently
Indent the body of every loop, IF statement, and subroutine by a consistent amount. In AQA pseudo-code, indentation is expected:
FOR i <- 0 TO 9
IF numbers[i] > max THEN
max <- numbers[i]
ENDIF
ENDFOR
Add Comments Where Helpful
A brief comment such as // Check if the number is prime above a loop demonstrates understanding to the examiner. Do not over-comment obvious lines.
Close All Structures
Every IF needs an ENDIF, every FOR an ENDFOR, every WHILE an ENDWHILE. Missing these is a common reason for lost marks. Write the opening and closing keywords first, then fill in the body.
Exam Technique for Code Questions
Code-Writing Questions
- Read the question twice. Identify exactly what the program should do, what inputs it receives, and what output is expected.
- Plan your approach. Before writing any code, decide which structures you need -- will you use a loop? Which type? Do you need selection? An array?
- Write the skeleton first. Set up your loops and conditions with their opening and closing keywords before filling in the detail.
- Use the correct AQA syntax. Write
<-for assignment, not=. UseOUTPUTandUSERINPUT. UseENDFOR,ENDWHILE,ENDIF. The mark scheme expects AQA pseudo-code or a named high-level language -- mixing conventions loses marks. - Trace through your answer. Pick a simple test case and mentally run through your code to verify it produces the correct output. This takes an extra minute but catches many errors.
Code-Correction Questions
These give you a program that contains errors and ask you to identify and fix them. Common errors to look for:
- Wrong comparison operator -- using
<instead of<=, or=instead of!= - Off-by-one errors in loops -- loop running one too many or one too few times
- Incorrect variable initialisation -- a counter starting at 1 instead of 0, or a max value starting at 0 when all values could be negative
- Logic errors in conditions -- using AND when OR is needed, or forgetting to use NOT
- Missing or misplaced statements -- an OUTPUT inside a loop that should be outside, or an assignment in the wrong order
Read the entire program first and understand what it is supposed to do, then compare that against what the code actually does. The gap between intent and implementation is where errors hide.
General Tips
- Show your working. Annotations and clear structure demonstrate understanding.
- Do not leave blanks. Write pseudo-code that communicates your logic even if you are unsure of exact syntax -- partial marks are available for correct reasoning.
- Manage your time. If a code question is taking too long, write what you can and move on. You can return to it later.
Prepare with LearningBro
Mastering programming and Boolean logic requires consistent practice with the right kinds of questions. LearningBro offers targeted courses that match the AQA GCSE Computer Science specification:
- AQA GCSE Computer Science: Programming Fundamentals -- practise variables, data types, selection, iteration, subroutines, arrays, string handling, and file operations with exam-style questions.
- AQA GCSE Computer Science: Boolean Logic -- build confidence with truth tables, logic gates, and Boolean expressions through structured practice.
- AQA GCSE Computer Science Exam Guide -- detailed exam technique for both Paper 1 and Paper 2, including trace tables, algorithm design, and extended answer strategy.
Work through these resources alongside your classroom learning, and you will develop the fluency and confidence you need to tackle any programming question the exam puts in front of you.
Good luck with your revision.