← VCE Software Development U4O1

Order of operations with brackets in Python

Python works out brackets first, so (a + b) / 2 adds a and b before dividing by 2. Without the brackets, the division would happen first and the average would be wrong.

Understanding Order of operations with brackets in Python in VCE Software Development U4O1

What it does: The brackets make 3 + 4 happen first, giving 7, then 7 * 2 gives 14. Without brackets the answer would be 11. Multiplication comes before addition, so 3 * 4 = 12 and then 2 + 12 = 14. Python does b / 2 first. The fix is total = (a + b) / 2. Brackets are worked out first, so the addition happens before the division. This is the correct way to average two values. The brackets are in the right place, but the divisor must match how many values are added: (a + b + c) / 3.

Common mistakes: Without brackets, Python divides b by 2 first and then adds a, so the result is 125.0, not 85.0. It should be average = (a + b) / 2. Multiplication happens before addition, so this gives 11, not 16. Brackets are needed to add first: total = (5 + 3) * 2.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 3–79) and word search (Modules 3–114).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which line correctly finds the average of a and b?
average = (a + b) / 2average = a + b / 2
Matches
average = a + b / 2
↓
The brackets are missing, so only b is divided by 2. It should be average = (a + b) / 2.
Applying
Meanings
Term
(a + b) / 2
Meaning
Python works out brackets first, so (a + b) / 2 adds a and b before dividing by 2. Without the brackets, the division would happen first and the average would be wrong.
Practice
a = 80
Testing
Gaps
average = (a + b) 2
Check Answer
Spots
1a, b = 80, 90
2average = a + b / 2

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Barreleye Fish' badge — Clear Vision, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which line correctly finds the average of a and b?
A. average = (a + b) / 2 ✓
B. average = a + b / 2
Without brackets, b / 2 is worked out first and then a is added. Brackets make Python add a and b before dividing.
2. What does this print? print(2 + 3 * 4)
A. 14 ✓
B. 20
Multiplication comes before addition, so 3 * 4 = 12 and then 2 + 12 = 14.
3. What does this print? print((2 + 3) * 4)
A. 14
B. 20 ✓
Brackets are worked out first, so 2 + 3 = 5 and then 5 * 4 = 20.
4. Which statement about Python's order of operations is true?
A. Brackets are worked out before **, * and / ✓
B. Addition is always worked out before multiplication
The order is brackets, then **, then * / // %, then + and -. Addition only goes first if you put it in brackets.
5. A student wants the average of three marks. Which line is correct?
A. avg = m1 + m2 + m3 / 3
B. avg = (m1 + m2 + m3) / 3 ✓
Without brackets only m3 is divided by 3. The brackets make Python add all three marks first.

Match the Pairs

(a + b) / 2 → Adds a and b first because of the brackets, then divides the total by 2 to find the average
a + b / 2 → Divides b by 2 first, then adds a, so it does not give the average of a and b
Brackets are worked out first, so they can force an addition to happen before a multiplication → total = (3 + 4) * 2
Python works out ** before * / // % and before + -, so the power is calculated first → result = 2 + 3 ** 2
average = a + b / 2 → The brackets are missing, so only b is divided by 2. It should be average = (a + b) / 2.
average = (a + b + c) / 2 → Three values are added but divided by 2. The total should be divided by 3 to find the average of three numbers.

Key Term

(a + b) / 2
Python works out brackets first, so (a + b) / 2 adds a and b before dividing by 2. Without the brackets, the division would happen first and the average would be wrong.

Fill in the Blanks

1. average = (a + b) / 2
Hint: Type the operator that divides the bracketed total.
2. total = (5 + 3) * 2 print(total)
Hint: Type the operator that multiplies the bracketed result by 2.
3. avg = (m1 + m2 + m3) / 3
Hint: Type the number of marks being averaged.
4. print((2 + 3) * 4)
Hint: Type the symbol that makes the addition happen before the multiplication.
5. print((2 + 3) ** 2)
Hint: Type the operator that raises the bracketed result to a power.

Spot the Error

Question 1
A a, b = 80, 90
B average = a + b / 2
C print(average)
Line B — Without brackets, Python divides b by 2 first and then adds a, so the result is 125.0, not 85.0. It should be average = (a + b) / 2.
Question 2
A total = 5 + 3 * 2
B print(total)
C print(total == 16)
Line A — Multiplication happens before addition, so this gives 11, not 16. Brackets are needed to add first: total = (5 + 3) * 2.
Question 3
A english = 70
B maths = 90
C average = english + maths / 2
D print(average)
Line C — Division is done before addition, so only maths is halved and the result is 115.0. It should be average = (english + maths) / 2.
Question 4
A square = 3 + 2 ** 2
B print(square)
C print(square == 25)
Line A — The ** operator runs before +, so this calculates 3 + 4 = 7. Brackets are needed to add first: square = (3 + 2) ** 2 gives 25.
Question 5
A ticket = 12
B total = ticket + 3 * 4
C print("Total:", total)
Line B — Multiplication happens first, so this gives 12 + 12 = 24, not 60. Brackets are needed: total = (ticket + 3) * 4.

Student with a class code? Join your class →