L4:Python
L4:Python
>>> 2 + 3 * 6
20
>>> (2 + 3) * 6
30
5
06/08/2018 Debajyoti Ghosh, Asst. Prof, BML Munjal University
Operator Associativity
Whenever two or more operators have the same precedence or an expression
contains more than one same operators, then associativity defines the order of
operations. Hence, associativity is the order in which Python evaluates an
expression containing multiple(or same) operators of the same precedence.
Almost all operators except the exponent (**) support the left-to-right
associativity.
5 * 2 // 3 = 3 // Left-right associativity