Skip to content

Numeric expressions

Arithmetic operators combine numbers into expressions, such as a total price.

Maya's receipt shows three items at $4 each and one $2 fee. She wants Python to work out the whole charge in a single line. How can one calculation get it right?

Start the lesson

5 minutes. No account needed.

What you'll learn
  • A numeric expression is a calculation written with numbers, like 3 * 4, which Python turns into 12.
  • Python multiplies with *, subtracts with - and divides with /, and / always gives a decimal answer like 4.5 or 4.0.
  • Python's order of operations does multiplying and dividing before adding and subtracting, so 5 + 2 * 6 gives 17.
  • When dividing and multiplying sit side by side, Python works from left to right, so 18 / 3 * 2 gives 12.0.
  • Python works out what's inside parentheses first, so (5 + 2) * 6 gives 42.
Lessons in Simple Python programs7 lessons · 29 min

Keep going with Python

We build you a study plan for each day. It fits your time and starts at this chapter.

Build my plan

Start free, no account needed. See prices