SLIDE 1
CSZone.co.uk
Click to advance · Arrow keys also work
Edexcel 1CP2 · Topic 6 · 6.2a

Arithmetic &
Comparison Operators

+ - * / // % ** · == != < > <= >= · BODMAS

CSZoneEdexcel GCSE Computer Science 1CP2
Arithmetic Operators

Maths in Python

print(10 + 3) # 13 addition
print(10 - 3) # 7 subtraction
print(10 * 3) # 30 multiplication
print(10 / 3) # 3.33 true division (float)
print(10 // 3) # 3 integer division (floor)
print(10 % 3) # 1 modulo (remainder)
print(2 ** 8) # 256 exponentiation
DIV (//) : gives whole-number quotient — essential for Edexcel
MOD (%): gives remainder — used to check even/odd: n % 2 == 0 means even
Python follows BODMAS: Brackets, Orders, Divide, Multiply, Add, Subtract
Comparison Operators

Testing Conditions

x = 10
print(x == 10) # True (equal to)
print(x != 5) # True (not equal)
print(x > 5) # True (greater than)
print(x < 5) # False (less than)
print(x >= 10) # True (greater or equal)
print(x <= 9) # False (less or equal)
Comparison operators always return True or False — they are boolean expressions
Critical: = is assignment; == is comparison — confusing these is a very common error
Combining Operators

Practical Examples

num = int(input("Enter number: "))

# Check if divisible by both 2 and 3
if num % 2 == 0 and num % 3 == 0:
print("Divisible by 6")

# Calculate grade
score = 85
percentage = score / 100 * 100
grade = "A" if score >= 70 else "B"
Assignment operators: +=, -=, *=, //= — shorthand for updating variables
Exam Practice

Have a go at this question

Edexcel-style question
What is the output of the following Python code?

x = 17
print(x // 5)
print(x % 5)
2 marks
17 // 5 = 3 (integer division — 5 goes into 17 three times) [1]. 17 % 5 = 2 (remainder after dividing 17 by 5) [1].
Key Takeaways

What to Remember

/ = float division; // = integer (floor) division; % = modulo (remainder)
** = exponentiation (2**8 = 256); follows BODMAS order of operations
Comparison: == != < > <= >= — always return True or False
= is assignment; == is comparison — confusing them causes logic errors