Lesson 2
The Basic Elements
Chapter 5: Operators and Expressions
Arithmetic operators
You can combine objects with operators like +
and -
to form expressions.
Expressions are something that can produce a value, for example 5+2
evaluates to 7
.
A literal on its own (5
) is also an expression.
The arithmetic operators in Python are quite straightforward:
+
(addition)-
(subtraction)*
(multiplication)/
(division)//
(floor division, or integer part of division)%
(modulo, or remainder after division)**
(exponential - raised to the power)
Try the quiz below! Make an informed guess before verifying your answer (no penalty for the wrong guess). If the quiz raises further thoughts and questions, test it out in a Python interactive prompt!
❮
❯