Study Notes

Overview
Operators are the 'verbs' of programming—they tell the computer what action to perform on data. Whether you are calculating a score, checking if a user has enough lives left, or combining complex conditions in an if statement, operators are at the heart of the process.
In GCSE Computer Science, operators are tested heavily. Examiners look for your ability to apply the correct operator to solve a problem, understand operator precedence (the order of evaluation), and differentiate between assignment and comparison. A solid grasp of operators is crucial because they connect directly to almost every other programming topic, including iteration, selection, and data representation.
Key Concepts
Concept 1: Arithmetic Operators
Arithmetic operators perform mathematical calculations. In Python (the standard language for GCSE Computer Science), there are seven primary arithmetic operators you must know. While addition (+), subtraction (-), multiplication (*), and standard division (/) work exactly as they do in maths, the others require special attention.
Integer Division (//): Also known as floor division, this operator divides two numbers and returns only the whole number part, discarding any remainder. Crucially, it always rounds down to the nearest integer.
Example: 10 // 3 evaluates to 3. However, -10 // 3 evaluates to -4 (because -3.33 rounds down to -4).
Modulus (%): The modulus operator returns the remainder after integer division. It is incredibly useful for determining if a number is even or odd (e.g., num % 2 == 0 means the number is even).
Example: 10 % 3 evaluates to 1, because 3 goes into 10 three times, leaving a remainder of 1.
Exponentiation (**): This operator raises a number to the power of another.
Example: 2 ** 3 means 2 cubed (2 × 2 × 2), which evaluates to 8.

Concept 2: Relational Operators
Relational operators compare two values and always evaluate to a Boolean result: True or False. They are the foundation of decision-making in code (selection).
- Equal to (
==): Checks if two values are identical. - Not equal to (
!=): Checks if two values are different. - Less than (
<) and Greater than (>): Standard mathematical inequalities. - Less than or equal to (
<=) and Greater than or equal to (>=): Inclusive inequalities.
Example: If score = 85, the expression score >= 50 evaluates to True.
Examiner Tip: The most common error is confusing the assignment operator (=) with the relational equality operator (==). Remember: one equals sign sets a value; two equals signs check a value.
Concept 3: Logical Operators
Logical operators combine multiple Boolean expressions or invert them. Python uses the keywords and, or, and not.
and: Evaluates toTrueonly if both conditions areTrue.or: Evaluates toTrueif at least one condition isTrue.not: Inverts the Boolean value (turnsTruetoFalse, and vice versa).
Example: (age >= 18) and (has_ticket == True) will only allow entry if the person is an adult and holds a ticket.

Concept 4: Operator Precedence
Just like BODMAS in mathematics, programming languages have a strict order of operations, known as operator precedence. If you mix different operators in a single expression, the computer evaluates them in a specific sequence.
- Parentheses
()(Highest priority) - Exponentiation
** - Multiplication
*, Division/, Integer Division//, Modulus%(Evaluated left-to-right) - Addition
+, Subtraction- - Relational operators (
==,<,>, etc.) - Logical
not - Logical
and - Logical
or(Lowest priority)
Example: In the expression 3 + 4 * 2, the multiplication happens first. 4 * 2 is 8, plus 3 is 11. If you wanted the addition to happen first, you must use parentheses: (3 + 4) * 2 equals 14.

Listen to our 10-minute podcast revision session for a complete walkthrough of these concepts:
Visual Resources
3 diagrams and illustrations
Interactive Diagrams
2 interactive diagrams to visualise key concepts
Conceptual Flow Outline
Flowchart showing the step-by-step process of operator precedence evaluation.
Conceptual Flow Outline
Using the modulus operator to determine if a number is even or odd.
Worked Examples
3 detailed examples with solutions and examiner commentary
Practice Questions
Test your understanding — click to reveal model answers
Calculate the result of the expression: 20 // 3 + 20 % 3
Hint: Evaluate the integer division and the modulus separately before adding them together.
Write a Python if statement that checks if a variable temperature is between 15 and 25 inclusive.
Hint: You need to check two conditions and combine them. 'Inclusive' means you should use the 'or equal to' operators.
Evaluate the following Boolean expression where x = 5 and y = 10: not (x == 5 and y < 5)
Hint: Work from the inside of the parentheses outward. Evaluate the `and` condition first, then apply the `not`.
Explain why the expression -5 // 2 results in -3 rather than -2.
Hint: Think about the mathematical definition of floor division and which direction it rounds on a number line.
A program contains the following line of code: is_valid = (score >= 50). State the data type of the variable is_valid.
Hint: What kind of value does a relational operator (`>=`) produce?