Skip to content

Latest commit

 

History

History
39 lines (33 loc) · 678 Bytes

arthemetic_operations_ precedence.md

File metadata and controls

39 lines (33 loc) · 678 Bytes
Operator Description
lowest precedence or Boolean OR
and Boolean AND
not Boolean NOT
==, !=, <, <=, >, >=, is, is not comparisons, identity
^ bitwise XOR
& bitwise AND
<<, >> bit shifts
+, - addition, subtraction
*, /, //, % multiplication, division, floor division, modulo
+x, -x, ~x unary positive, unary negation, bitwise negation
highest precedence ** exponentiation

Example 1

>>> 20 + 4 * 10
60
>>> (20 + 4) * 10
240

>>> 2 * 3 ** 4 * 5
810
>>> 2 * 3 ** (4 * 5)
6973568802

Example 2 (Augmented Assignment Operators)

>>> a = 10
>>> b = 20
>>> c = a * 5 + b
>>> c
70