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
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 / bCode
answer = (4 + 6) * 3
print(answer)Output
30
Why it works
- Parentheses calculate 4 + 6 first.
- Python multiplies 10 by 3.
- answer stores 30 for print().
Common mistake
Not this
4 + 6 * 3 # expecting 30Try this
(4 + 6) * 3Without parentheses, multiplication happens before addition.