Index Ai Academy
Foundation · Foundation mathNumbers

Order of operations, and names for numbers

About 36 minLooking ahead: some prerequisites aren't done yet

Why this matters

What is 4 + 3 × 2? If one person gets 14 and another gets 10, a calculation means two things, and nobody can trust it. So everyone agrees on an order. Python follows the same order, and every formula in AI depends on it. This lesson shows the order, how brackets override it, and how to give numbers names so a long calculation reads like plain sense.

  • Work a calculation in the agreed order: brackets, powers, multiply and divide, then add and subtract
  • Place brackets to make a calculation mean what you intend
  • Give numbers names in Python with variables, and print a label with a value
  • Read a model's formula, such as w * x + b, in the right order
Quick check
Have a guess before you start. What is 4 + 3 × 2 − 1?

The math: one calculation, one answer

Purpose. A calculation has to mean the same thing to everyone who reads it, so there's an agreed order:

  1. Brackets first: anything inside brackets is worked out before the rest.
  2. Powers, like 3² (you'll meet them properly in the powers lesson).
  3. Multiply and divide, from left to right.
  4. Add and subtract, from left to right.

So in 4 + 3 × 2 − 1, the multiplication goes first: 3 × 2 = 6. That leaves 4 + 6 − 1, which you work left to right: 10, then 9.

Brackets override the order. If you meant "4 plus 3, then times 2", write it: (4 + 3) × 2 = 14. Brackets say "do this part first", whatever it holds.

The flow below works 4 + 3 × 2 − 1 one operation at a time, and its picture draws the calculation as a tree. Each operation sits above the two numbers it works on, so the one that happens last is at the top. Each step folds one operation into its answer, from the bottom up, until a single number is left.