Python operators
Python operators
Arithmetic operators
Assignment operators
Comparison operators
Logical operators
Identity operators
Membership operators
Bitwise operators
+ Addition x+y
- Subtraction x-y
* Multiplication x*y
/ Division x/y
% Modulus x%y
** Exponentiation x ** y
// Floor division(round the x // y
result. Eg:15/2 =7)
= x=5 x=5
+= x += 3 x=x+3
-= x -= 3 x=x-3
*= x *= 3 x=x*3
/= x /= 3 x=x/3
%= x %= 3 x=x%3
//= x //= 3 x = x // 3
**= x **= 3 x = x ** 3
&= x &= 3 x=x&3
|= x |= 3 x=x|3
^= x ^= 3 x=x^3
== Equal x == y
!= Not equal x != y
not Reverse the result, returns False not(x < 5 and x < 10)
if the result is true
in Returns True if a x in y
sequence with the
specified value is
present in the object
<< Zero fill Shift left by pushing zeros in from the right and let the leftmost bits fall off
left shift
>> Signed Shift right by pushing copies of the leftmost bit in from the left, and let the rightmost bits fall off
right shift