GCSE · Computer Science · Eduqas · Spec C500QS
Mathematical and logical operations in code
Quick bet: what does Python 3 say 6 / 2 is? If you said 3, brace yourself. It says 3.0, and that is only the first surprise.
Computer Science · Operators
Be the interpreter: call every value
Eleven lines of Python. For each marked line, decide what the variable will hold before the page shows you.
Nothing is run here: every value is the lesson's. Step on with Next, and call each marked line before the page reveals it.
total = 17groups = total // 5left = total % 5average = 7 / 2ratio = 6 / 2answer = 2 + 3 * 4bracketed = (2 + 3) * 4score = 50passed = score >= 50above = score > 50result = passed and not above
Variables
Step 1. total holds 17. This first line is worked for you. From here on, you call each value before it appears.
Computer Science · Choosing the operator
Which operator does the job?
Each line is something a program needs to work out. Pick the operator that does the job, then read why.
Still to sort
/ (true division) (0)
The exact value, decimal part kept
Where the line is: Use it when a decimal answer is fine. / always returns a float.
// (whole-number part) (0)
How many whole times it fits
Where the line is: Use it when the answer must be a whole number and the remainder is discarded.
% (remainder) (0)
What is left over
Where the line is: Use it for leftovers, and for testing whether a number divides exactly.
A comparison (==, >, <=...) (0)
A True or False answer about two values
Where the line is: Comparisons give True or False, never a number.
and / or / not (0)
Joining or flipping whole conditions
Where the line is: Use these when a rule needs more than one condition, or the opposite of one.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
Be the interpreter: work out what each line really gives, one operator at a time.
What you need to know
- An expression combines values, variables and operators, and evaluating it always gives a single result.
- Python 3's arithmetic operators are +, -, *, / (division), // (integer division), % (modulus, the remainder) and ** (power).
- The / operator always returns a float, even when the division is exact: 7 / 2 is 3.5 and 6 / 2 is 3.0.
Have a goA classmate swears 10 / 5 'obviously' gives 2, because it divides exactly. Be kind, but correct them: what does Python 3 give?
2.0 (a float)
/ always returns a float, even when the division is exact, so an exact answer still carries the .0.
- // keeps the whole-number part, so 17 // 5 is 3. % keeps the remainder, so 17 % 5 is 2.
- // rounds down towards negative infinity, so -7 // 2 is -4, not -3.
Have a goPredict before you look: what is -9 // 2? Think about which way is down.
-5
-9 / 2 is -4.5, and // rounds down towards negative infinity, so it lands on -5, not -4.
- // and % work as a pair: 17 = 3 * 5 + 2, which is how total // 60 and total % 60 turn minutes into hours and minutes.
- Arithmetic order: ** first, then * / // % left to right, then + and -. Brackets go before all of it.
Have a goWork out 10 - 2 * 3 and (10 - 2) * 3. Which one is bigger?
(10 - 2) * 3 is 24; 10 - 2 * 3 is 4
The multiplication happens before the subtraction by default; the brackets force the subtraction first.
- Comparisons (==, !=, <, >, <=, >=) give True or False, and the boundary matters: at 50, score >= 50 is True but score > 50 is False.
- = assigns a value; == compares two values for equality. Writing = where a comparison is intended is an error.
- and needs both conditions True, or needs at least one, and not reverses a result. Each side must be complete: x == 1 or x == 2.
The big picture
An expression is built from values, variables and operators, and always boils down to one value. Python's own rules decide that value: / returns a float, // floors, % gives the remainder, precedence and brackets set the order, comparisons give True or False, and and / or / not combine complete conditions.
Key points
Worked example
Problem
age holds 65. Work out the value of age >= 13 and age <= 19 or age == 65
⚠ Watch out
Reading code like English or like a calculator: expecting 6 / 2 to be 3, -7 // 2 to be -3, = to mean the same as ==, or x == 1 or 2 to test both values. Evaluate each operator by its own rule instead.
Memory hook
Be the interpreter: one operator at a time, in Python's order, and commit to a value before you check it.
Check yourself
Without running anything, work out 14 / 7, 14 // 4, 14 % 4 and 3 + 4 * 2. Then check: 2.0, 3, 2 and 11.
Flashcards
(15)What does evaluating an expression give you?
Name the seven Python 3 arithmetic operators.
What does / give in Python 3, even when the division is exact?
What does // give?
What does // do with a negative result?
What does % give?
How do // and % rebuild a number?
How do you test whether n is exactly divisible by k?
In what order does Python 3 evaluate arithmetic?
What does a comparison evaluate to?
What is the difference between = and ==?
Why does the boundary value matter when you choose a comparison?
What do and, or and not do?
In what order are the parts of a compound condition evaluated?
What is wrong with x == 1 or 2?
Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.
Learning with Lightbulb is opening soon
You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.
Keep me postedMore Eduqas GCSE Computer Science topics
- File handling: open a file
- File handling: read into a variable
- File handling: read into an array
- File handling: write to a file
- Iteration: condition and counter controlled loops
- Lists, tuples and dictionaries
- Modular structuring with abstraction
- Presenting test outcomes with commentary
- Program a solution to requirements
- Refining code during development
- Selection in programs
- Sequence in programs
How this lesson was checked. This Eduqas GCSE Computer Science (specification C500QS)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 16 November 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.