Precedence of Operators¶
Precedence of operators is used by the python interpreter to determine the output of an expression.
Python follows the below order of precedence on operators.
- Parentheses
- Exponentiation
- Multiplication and Division
- Addition and Subtraction
Note: Operators with the same precedence are evaluated from left-to-right.
Try by yourself¶
Guess the output of below expressions?
19 - 12 * 2
61 - 12 + 12
61 - (12 + 12)