🐍 Paper 2 · Topic 6: Programming
6.2a Arithmetic & Comparison Operators
Edexcel 1CP2 · GCSE Computer Science · ~10 min read · ✅ Free
Notes
──
Video
──
Slides
──
Worksheet
──
Quiz

Arithmetic Operators

Arithmetic operators perform mathematical calculations. Python supports all standard maths operations:

OperatorNameExampleResult
+Addition7 + 310
-Subtraction7 - 34
*Multiplication7 * 321
/Division (float result)7 / 23.5
//Integer division (DIV)7 // 23
%Modulus / remainder (MOD)7 % 21
**Exponentiation (power)2 ** 8256

DIV and MOD — key operators for Edexcel

DIV (//): Integer division — divides and discards the remainder (floor division)

MOD (%): Gives the remainder after division. Very useful for:

  • Checking if a number is even: n % 2 == 0
  • Checking if a number is divisible by something: n % 5 == 0
  • Extracting digits: n % 10 gives the units digit
# DIV and MOD examples print(17 // 5) # 3 (17 divided by 5 = 3 remainder 2, DIV gives 3) print(17 % 5) # 2 (17 divided by 5 = 3 remainder 2, MOD gives 2) print(8 % 2) # 0 (8 is divisible by 2, so remainder is 0 = even) print(7 % 2) # 1 (7 is odd, remainder = 1)

Operator Precedence (BIDMAS)

Python follows BIDMAS/BODMAS order:

  • Brackets () — highest priority
  • Indices (Exponentiation) **
  • Division / and Multiplication * (equal priority, left to right)
  • Addition + and Subtraction - (lowest)
print(2 + 3 * 4) # 14, not 20 — multiply before add print((2 + 3) * 4) # 20 — brackets first print(2 ** 3 + 1) # 9 — exponent before add: 8+1=9

Comparison Operators

Comparison operators compare two values and return a Boolean (True or False). Used in if statements and while conditions:

OperatorMeaningExampleResult
==Equal to5 == 5True
!=Not equal to5 != 3True
>Greater than7 > 3True
<Less than3 < 7True
>=Greater than or equal to5 >= 5True
<=Less than or equal to4 <= 3False
# Comparison examples score = 65 print(score >= 60) # True print(score == 100) # False print(score != 0) # True # In conditions if score >= 50: print("Pass")

Assignment Operators

Shorthand operators for updating variables:

OperatorExampleEquivalent to
+=x += 5x = x + 5
-=x -= 3x = x - 3
*=x *= 2x = x * 2
//=x //= 2x = x // 2
Exam tip: The % (modulo) and // (integer division) operators come up very often in Edexcel exams. Know that x % 2 == 0 checks for even numbers. Know that 17 // 5 = 3 and 17 % 5 = 2 (because 5×3=15, remainder 2).
⚠️ Common Mistakes
  • Using = (assignment) instead of == (equality check) in a condition
  • Thinking 7 / 2 = 3 — in Python 3, / always gives a float (3.5). Use // for integer division
  • Getting BIDMAS wrong — 2 + 3 * 4 = 14, not 20
  • In Edexcel pseudocode: DIV is written as DIV and MOD as MOD, not // or %
Video coming soon
Click slide or press arrow keys to navigate
✍️

Worksheet — 6.2a Operators

8 Edexcel-style questions · instantly marked

Q1State the result of each expression: (a) 20 // 3 (b) 20 % 3 (c) 2 ** 4 (d) 15 / 4[4]
✅ Mark scheme
(a) 6 [1]; (b) 2 [1]; (c) 16 [1]; (d) 3.75 [1]. Note: 20 ÷ 3 = 6 remainder 2, so DIV=6, MOD=2. 2**4 = 2×2×2×2 = 16. 15/4 = 3.75 (float division in Python 3).
Q2What is the output of: print(2 + 3 * 4 - 1) ? Show your working.[2]
✅ Mark scheme
13 [1]; Working: multiplication first: 3*4=12, then left to right: 2+12=14, 14-1=13 [1].
Q3Write Python code to check if a number stored in a variable n is divisible by both 3 and 5 (i.e., divisible by 15).[2]
✅ Mark scheme
if n % 3 == 0 and n % 5 == 0: [2] (award 1 mark for n % 15 == 0 as an alternative). Must use == not =.
Q4Explain the difference between / and // in Python. Give an example of each.[4]
✅ Mark scheme
/ performs regular division and always returns a float [1]; e.g. 7 / 2 = 3.5 [1]; // performs integer (floor) division — divides and discards the remainder, returning an integer [1]; e.g. 7 // 2 = 3 [1].
Q5A program stores a time in total seconds. Write Python code to display it as minutes and seconds (e.g. 125 seconds = 2 mins 5 secs).[3]
✅ Mark scheme
total = 125 (or any variable) [accept if already declared]; minutes = total // 60 [1]; seconds = total % 60 [1]; print(str(minutes) + " mins " + str(seconds) + " secs") or equivalent [1].
Q6Evaluate each comparison and state True or False: (a) 10 != 10 (b) 7 >= 7 (c) 3 < 3 (d) 5 == 5.0[4]
✅ Mark scheme
(a) False [1]; (b) True [1]; (c) False — 3 is not strictly less than 3 [1]; (d) True — Python considers integer 5 equal to float 5.0 [1].
Q7A student writes: if age = 18: print("adult"). Identify the error and correct it.[2]
✅ Mark scheme
Error: = is the assignment operator, not a comparison operator [1]; Correction: if age == 18: — must use double equals == to compare [1].
Q8In Edexcel pseudocode, what symbols are used for: (a) integer division, (b) modulus/remainder, (c) not equal to?[3]
✅ Mark scheme
(a) DIV [1]; (b) MOD [1]; (c) ≠ or != [1] — Edexcel uses DIV and MOD as keywords in pseudocode rather than // and %.
Topic Quiz
Q 1 of 15
You scored
out of 15
Click to reveal definition
🎉
Session complete!
TermDefinition
🎯

Mini Test — Operators

Timed exam-style test — 10 minutes.

← 6.1c SubroutinesTopic 6 · PythonNext: 6.2b Logical & String Ops →