Step 1 · Read and run
Which goes first?
What's 2 + 3 * 4? If you add first you get 20. If you multiply first you get 14.
Python follows the same order as in maths (you may know it as BIDMAS or BODMAS):
- Brackets first.
- Then powers:
** - Then
*,/,//and%, working from left to right. - Then
+and-, working from left to right.
So 2 + 3 * 4 multiplies first: 2 + 12 = 14. Brackets let you change that: (2 + 3) * 4 adds first.
Run it.
Run the program to carry on.