- How arithmetic operators calculate numeric values in algorithms.
- How relational operators compare values and produce
True or False.
- How logical operators
AND, OR and NOT combine conditions.
- How to follow and write Python 3 conditions correctly for GCSE algorithms.
An algorithm is a finite set of ordered steps used to solve a problem. In this topic, you are mainly looking at the small “working parts” inside those steps: calculations and decisions.
A value is a piece of data, such as 42, "hello" or True. A variable is a named storage location for a value, such as score or age.
Operator
An operator is a symbol or word that performs an action on one or more values. The values it works on are called operands. For example, in score + 10, the operator is + and the operands are score and 10.
An expression is a combination of values, variables and operators that produces a result. For example, score + bonus * 2 is an arithmetic expression because it calculates a number.
This overview shows how the three operator families fit together: arithmetic calculates numbers, relational comparisons produce Boolean values, and logical operators combine those Boolean values for decisions.

Boolean
A Boolean is a data type with only two possible values: True or False. Relational and logical operators produce Boolean results.
Arithmetic operators are used for calculations. They usually take numbers as input and produce a number as output.
| Operator in Python 3 | Name | Meaning |
|---|
+ | addition | Add two values |
- | subtraction | Subtract one value from another |
* | multiplication | Multiply two values |
/ | division | Divide and allow a decimal result |
// | integer division | Divide and keep the whole-number quotient |
% | modulus | Find the remainder after division |
** | exponentiation | Raise to a power |
Two operators are especially important in algorithms:
// gives how many whole groups fit.
% gives what is left over.
For positive integers, if you divide 37 by 5, you can make 7 full groups with 2 left over. So 37 // 5 is 7, and 37 % 5 is 2.
Splitting counters into full boxes
A program has 37 counters. Each box holds 5 counters. Work out how many full boxes can be made and how many counters are left over.
- Use integer division to find the number of full boxes:
37 // 5 gives 7, because 5 fits into 37 seven whole times.
- Use modulus to find the remainder:
37 % 5 gives 2, because after making 7 full boxes, 2 counters are left.
- Check the relationship: 37=7×5+237 = 7 \times 5 + 237=7×5+2, so the quotient and remainder make sense.
Remember // and % together
Think of // as “how many full groups?” and % as “what is left over?”
When an expression has several arithmetic operators, Python follows an order of operations:
- Brackets first.
- Exponentiation, such as
**.
- Multiplication, division, integer division and modulus.
- Addition and subtraction.
Use brackets whenever they make your meaning clearer. This is especially useful in exams, because it reduces the chance of reading the expression incorrectly.
Evaluating an arithmetic expression
Evaluate 3 + 4 * 2 ** 3.
- Apply exponentiation first:
2 ** 3 gives 8.
- Apply multiplication next:
4 * 8 gives 32.
- Apply addition last:
3 + 32 gives 35.
Doing arithmetic strictly left to right
Do not evaluate 3 + 4 * 2 as if it were (3 + 4) * 2. Multiplication happens before addition unless brackets say otherwise.
Relational operators compare two values. The result is always a Boolean: True or False.
| Operator in Python 3 | Name | Example meaning |
|---|
== | equal to | score == 10 means score is equal to 10 |
< | less than | age < 18 means age is less than 18 |
> | greater than | height > 150 means height is greater than 150 |
!= | not equal to | choice != "Q" means choice is not Q |
<= | less than or equal to | mark <= 100 means mark is at most 100 |
>= | greater than or equal to | score >= pass_mark means score is at least the pass mark |
Condition
A condition is an expression that evaluates to True or False. Conditions are used in selection, such as if, and iteration, such as while.
Comparing a score with boundaries
Suppose score = 64, pass_mark = 50 and merit_mark = 70. Evaluate score >= pass_mark and score >= merit_mark.
- Compare the score with the pass mark:
64 >= 50 is True, because 64 is greater than 50.
- Compare the score with the merit mark:
64 >= 70 is False, because 64 is less than 70.
- Use the Boolean results in decisions: the student has passed, but has not reached the merit mark.
Using = instead of ==
In Python, = assigns a value to a variable, such as score = 10. To test equality, use ==, such as score == 10.
Logical operators work with Boolean values. They are used to combine or invert conditions.
The three logical operators you need are:
AND: result is True only if both conditions are True.
OR: result is True if at least one condition is True.
NOT: reverses a Boolean value, so True becomes False and False becomes True.
In informal algorithms and exam explanations, you may see AND, OR and NOT. In Python 3 code, write them in lowercase as and, or and not.
Logical operators make decisions more precise
Relational operators create individual True or False tests. Logical operators combine those tests so an algorithm can make more detailed decisions.
Combining conditions for access
A game lets a player start a level only if they have at least one life, at least 10 energy, and the game is not paused. Suppose lives = 2, energy = 8 and game_paused = False.
- Evaluate the first comparison:
lives > 0 is True, because 2 is greater than 0.
- Evaluate the second comparison:
energy >= 10 is False, because 8 is less than 10.
- Evaluate the
NOT part: not game_paused is True, because game_paused is False.
- Combine using
and: True and False and True gives False, so the player cannot start the level.
Treating OR as exclusive
In GCSE Computer Science, OR is inclusive. This means A OR B is True when A is true, when B is true, or when both are true.
When you write an algorithm, operators often appear inside assignment statements, if statements and loops.
For example:
total = price * quantity uses arithmetic.
if total >= 100: uses a relational operator.
if total >= 100 and member == True: combines conditions with a logical operator.
You can often make Boolean conditions neater. Instead of writing member == True, you can simply write member if member already stores a Boolean value. Instead of member == False, you can write not member.
A range check tests whether a value is inside an allowed range. For example, to check whether age is between 11 and 16 inclusive, both comparisons must be true:
age >= 11 and age <= 16
You can also write this in Python as:
11 <= age <= 16
Both versions are valid Python, but the first version makes the two separate relational comparisons very clear.
Writing a condition for a discount
A shop gives a discount if a customer buys at least 3 items and the total cost is greater than 20. Write the condition.
- Translate “at least 3 items” into a comparison:
number_of_items >= 3.
- Translate “total cost is greater than 20” into a comparison:
total_cost > 20.
- Both conditions must be true, so combine them with
and: number_of_items >= 3 and total_cost > 20.
In an exam, you may be asked to trace an algorithm. This means you carefully follow each line and keep track of variable values.
Consider this Python-style algorithm:
items = 14
boxes = items // 4
left_over = items % 4
order_complete = left_over == 0
needs_extra_box = boxes >= 3 and not order_complete
Tracing mixed operators
Follow the algorithm and find the value of needs_extra_box.
- Calculate full boxes using integer division:
14 // 4 gives 3, so boxes becomes 3.
- Calculate the remainder using modulus:
14 % 4 gives 2, so left_over becomes 2.
- Compare the remainder with zero:
left_over == 0 is 2 == 0, which is False, so order_complete becomes False.
- Evaluate the final logical expression:
boxes >= 3 is True, and not order_complete is also True.
- Combine the two Boolean values:
True and True gives True, so needs_extra_box is True.
Use brackets for readability
not, and and or have their own precedence rules, but you should use brackets to make complex conditions clear, such as (age >= 11 and age <= 16) and not is_banned.
In the exam
- Work out arithmetic expressions first, then relational comparisons, then logical combinations.
- Be precise with Python symbols: use
== for equality, // for integer division, % for remainder, and lowercase and, or, not in code.
- When tracing, write down each new variable value and each Boolean result before combining conditions.
Check yourself
- What are the results of
23 // 5 and 23 % 5, and what do they mean?
- Why does
score = 10 mean something different from score == 10 in Python?
- For
A OR B, which input combinations make the result True?