☞When an expression or statement involves multiple operators, Python resolves the order of execution through Operator Precedence.
☞Example : 2 * 3 / 5
☞Associativity is the order in which an expression having multiple operators of same precedence is evaluated.
☞Example : 2 * 3 / 5 * 9
☞Table of precedence of operators and associativity is given below :
Operator Precedence | Associativity |
---|---|
() | L to R |
** | R to L |
~ (unary) | L to R |
+ - (unary) | |
* / % // | |
+ - (binary) | |
& | |
^ | |
| | |
< <= > >= == != is, is not, in, not in | |
not | |
and | |
or |