Skip to content

Python arithmetic expressions

Use arithmetic expressions to calculate a trade's value and check that the units make sense.

Malik opens his trading app and sees a stock at $24.50 a share, which is one small piece of a company. He wants six shares, but the app asks for far more than $24.50. How could Python work out what he needs?

Start the lesson

5 minutes. No account needed.

What you'll learn
  • An arithmetic expression like 24.5 * 6 combines numbers with *, /, + or - to calculate one value.
  • Python does multiplication before addition and subtraction, so 2 + 20 * 3 gives 62.
  • Dollars per share times shares gives dollars, and dollars divided by shares gives dollars per share.
  • Parentheses make Python calculate the part inside first, so (10 + 2) * 5 gives 60.
Lessons in Financial calculations in Python7 lessons · 28 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