GCSE · Computer Science · OCR · Spec J277
Operators (arithmetic and Boolean)
17 / 5 gives 3.4. 17 // 5 gives 3. 17 % 5 gives 2. Same two numbers, three right answers. So which question is each operator asking?
Computer Science · Operators
Watch Python work it out
Six lines of Python. Step through them and watch each expression shrink, one rule at a time, until only a value is left.
Before you press Next: what number do you think ends up in result?
1 result = (2 + 3) * 4 ** 2 - 10 / 42 print(result)3 exact = 17 / 54 whole = 17 // 55 left = 17 % 56 print(exact, whole, left)
| expression now | result | exact | whole | left |
|---|---|---|---|---|
| (2 + 3) * 4 ** 2 - 10 / 4 |
Output
Step 1: Python can't swallow this in one go. It works through it in a fixed order. Which part do you think goes first?
The 'expression now' column isn't a variable. It shows the expression as it stands after each rule is applied.
Predict, then check
Picture actually handing them out, one at a time.
You share 14 counters between 3 people. In Python, what do 14 // 3 and 14 % 3 give?
Computer Science · Kinds of expression
Number, or True/False?
Pick an expression, then choose the kind of expression it is.
Still to sort
Arithmetic: gives a number (0)
Built with arithmetic operators such as +, -, *, / and **. The result is a numeric value.
Where the line is: A number can sit inside a comparison, as in 3 * 4 > 10. Once there's a comparison, the final result is True or False, so it's no longer just arithmetic.
Relational: compares, gives True or False (0)
One comparison using ==, !=, <, <=, > or >=.
Where the line is: One comparison on its own is relational. Join comparisons with and or or, or put not in front, and it becomes logical.
Logical: combines comparisons (0)
Uses the operators and, or and not with relational expressions. Operators can be words, not just symbols. Still gives one True or False.
Eight expressions. The test for each one: what does it give back, and how many comparisons are in it?
Computer Science · Conditions in selection
Which way does the program go?
Try three ages: 8, 35 and 72. Follow the route each one takes, and see where it ends up.
First comparison → Second comparison
3 possible routes.
One condition, three possible ages. Each age takes exactly one route.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
Python can divide two numbers three different ways. By the end you'll know which one you're asking for, and why one = sign is not the same as two.
What you need to know
- An operator is a symbol or word that tells the computer to do a specific calculation or action.
- Python's arithmetic operators: + add, - subtract, * multiply, / divide, ** to the power of. An arithmetic expression gives a number.
- Order matters: brackets first, then indices (powers), then multiplication and division, and addition and subtraction last.
Have a goYour friend is certain 1 + 2 * 3 comes out as 9 in Python. Before you look: are they right?
No. It's 7.
Multiplication comes before addition, so 2 * 3 = 6 is done first, then 1 + 6. Your friend just went left to right.
- Real division (/) divides the entire value, so there's no remainder: 9 / 2 is 4.5.
- Integer division (also called floor division, // in Python) discards the remainder and leaves a whole number.
- Modulo (MOD, written % in Python) gives you only the remainder.
Have a goQuick one: what's 20 // 6, and what's 20 % 6?
3 and 2.
6 goes into 20 three whole times (that's 18), so // gives 3. The 2 left over is what % gives. Mixing them up swaps the two answers.
- Relational operators compare values and give True or False: == equal to, != not equal to, plus <, <=, > and >=.
Have a goTrue or False? First 7 != 7, then 7 <= 8.
False, then True.
!= means 'not equal to', and 7 is equal to 7, so it's False. <= means 'less than or equal to', and 7 is less than 8, so it's True.
- In Python, one = assigns a value; two == compares two values.
- Logical operators and, or and not combine comparisons into one True or False: a logical expression.
- Relational and logical expressions can be conditions in selection, deciding which way the program goes.
The big picture
An operator is a symbol or word that tells the computer to do a calculation or action. Arithmetic expressions (+, -, *, /, ** in Python) give a number, worked out in order: brackets, indices, multiplication and division, then addition and subtraction. / keeps the whole value, // throws the remainder away, and % (MOD) gives only the remainder. Relational operators compare values and give True or False; one = assigns, two == compares. Logical operators and, or and not combine comparisons, and these expressions act as conditions in selection.
Key points
Worked example
Problem
A game runs bonus = (7 + 5) // 5 + 2 ** 3 and then checks the condition bonus > 9 and bonus != 10. What is stored in bonus, and is the condition True or False?
⚠ Watch out
Writing = when you mean ==. A single = assigns, so it puts a value into a variable. To check whether two values are equal, as in a condition, you need the comparison operator ==.
Memory hook
One = puts a value in. Two == asks a question. And when dividing: / keeps it all, // keeps the whole part, % keeps the leftovers.
Check yourself
Cover the page. Work out (6 + 2) ** 2 // 5, naming the rule you use at each step. Then explain why 64 % 5 and 64 // 5 give different answers.
Flashcards
(15)What is an operator?
What does an arithmetic expression result in?
What does ** do in Python?
Put these in the order Python works them out: addition and subtraction, brackets, multiplication and division, indices.
Why does real division (/) never leave a remainder?
What happens to the remainder in integer (floor) division, and how is it written in Python?
What does modulo (MOD) return, and what is its Python symbol?
What do relational operators do, and what does a relational expression evaluate to?
What does != mean?
What is the difference between = and == in Python?
When is an and expression True?
When is an or expression True?
When is not True?
What is a logical expression?
Where are relational and logical expressions used to control program flow?
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 OCR GCSE Computer Science topics
How this lesson was checked. This OCR GCSE Computer Science (specification J277)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 3 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.