Module 6 of 15 · Step 1 of 12

Operators

Operators calculate values and ask true-or-false questions. The symbols are short, so learn what each one produces before combining them.

By the end of this lesson, you can:
  • Use arithmetic and powers
  • Compare values
  • Combine Boolean conditions
  • Tell = from ==
  • Update a value with += or -=
Operators lesson progress0%

Course progress: 0% · 0 of 12 steps completed in this module

Learn · Calculate with arithmetic
Concept 1 of 5

Calculate with arithmetic

+ adds, - subtracts, * multiplies, and / divides. Regular division produces a float. Parentheses make a chosen part of a calculation happen first.

Pattern
a + b   a - b   a * b   a / b
Code
answer = (4 + 6) * 3
print(answer)
Output
30

Why it works

  1. Parentheses calculate 4 + 6 first.
  2. Python multiplies 10 by 3.
  3. answer stores 30 for print().

Common mistake

Not this
4 + 6 * 3  # expecting 30
Try this
(4 + 6) * 3

Without parentheses, multiplication happens before addition.