Back

Arithmetic operators - Answers

Q1. Students should look-up symbols they do not know rather than be given them.

Questions Answers 
3 + 20  23
10 + 2 * 2  40
5 + 20 / 5
10 / 2 - 1
2 ** 3
3*1**3
2 ** 1 + 2 4
12 / 8 1.5 
12 // 8  1
20 // 3
20 // 40
10 % 3
8 % 12  8
5 % 5
(2 + 1) * 2
3 * (3 - 1)  6
10.0 / 5.0 2.0 
10 / 5  2.0
10 / 0  Error - can't divide by zero
'23'+'3' 233 (adding strings not numbers)
5*'spam' spamspamspamspamspam (multiplying strings)
6*eggs Error - eggs is an undefined object

Q2. Students should compare and discuss their answers before trying them out in Python.

Q3. Students should look-up any terms they are unfamilar with rather than be given them.

Mixed-up list Correct order of precedence - Highest to lowest 
multiplication  brackets
MOD powers 
powers multiplication, division, integer division, MOD 
brackets  addition, subtraction
subtraction  
division  
add  
integer division  

Q4. Students should compare and discuss their answers before trying them out in Python. Search for operator precedence in Python 3. The Python official documentation contains a full list of operator precedence.

Back