Precedence of maths operators
You can use brackets in your maths to make sure everything is done in the correct order. For example the code below produces two different values –
print (4 *5) + 6 print 4 * (5 + 6) print 4 * 5 + 6
Brackets tell python the order you wish to do things in. Did you notice that 4 * 5 + 6 produced the same answer as (4 *5) + 6? This is because python will do the multiply first and then the plus. This is known as operator precedence or just precedence. The same thing happens in maths so hopefully this idea is not too alien!
Where should the brackets go in the calculation 3 * 5 + 2 to produce the answer 21? Enter the code below to move onto the next task
Output: (clear)











