Lesson 2
The Basic Elements
Chapter 5: Operators and Expressions
Operator precedence
You can also chain expressions, e.g. 7 + 2 * 3
.
Python largely obeys a standard order of operations in Mathematics.
More specifically, the operator precedence in Python is as follows.
( )
**
* // / %
+ -
If at equal precedence (e.g. multiplication and division), the expression is evaluated from left to right like in Mathematics.
Check whether you understand this with the quiz below!
❮
❯