2.1.3.9 Operators - data manipulation tools
List of priorities
Since you're new to Python operators, we don't want to present the complete list of operator priorities right now.
Instead, we'll show you its truncated form, and we'll expand it consistently as we introduce new operators.
Look at the table below:
Priority | Operator | |
---|---|---|
1 | + , - | unary |
2 | ** | |
3 | * , / , % | |
4 | + , - | binary |
Note: we've enumerated the operators in order from the highest (1) to the lowest (4) priorities.
Try to work through the following expression:
print(2 * 3 % 5)
Both operators (
*
and %
) have the same priority, so the result can be guessed only when you know the binding direction. How do you think? What is the result?
Comments
Post a Comment