1#PYTHON RELATIONAL OPERATORS
2OPERATOR DESCRIPTION SYNTAX FUNCTION IN-PLACE METHOD
3> Greater than a > b gt(a, b) __gt__(self, other)
4>= Greater or equal to a >= b ge(a, b) __ge__(self, other)
5< Less than a < b lt(a, b) __lt__(self, other)
6<= Less or equal to a <= b le(a, b) __le__(self, other)
7== Equal to a == b eq(a, b) __eq__(self, other)
8!= Not equal to a != b ne(a, b) __ne__(self, other)
9
10#PYTHON MATHEMATICAL OPERATORS
11OPERATOR DESCRIPTION SYNTAX FUNCTION IN-PLACE METHOD
12+ Addition a + b add(a, b) __add__(self, other)
13– Subtraction a - b sub(a, b) __sub__(self, other)
14* Multiplication a * b mul(a, b) __mul__(self, other)
15/ True Division a / b truediv(a, b) __truediv__(self, other)
16// Floor Division a // b floordiv(a, b) __floordiv__(self, other)
17% Modulo a % b mod(a, b) __mod__(self, other)
18** Power a ** b pow(a, b) __pow__(self, other)
19
20#PYTHON BITWISE OPERATORS
21OPERATOR DESCRIPTION SYNTAX FUNCTION IN-PLACE METHOD
22& Bitwise AND a & b and_(a, b) __and__(self, other)
23| Bitwise OR a | b or_(a,b) __or__(self, other)
24^ Bitwise XOR a ^ b xor(a, b) __xor__(self, other)
25~ Bitwise NOT ~ a invert(a) __invert__(self)
26>> Bitwise R shift a >> b rshift(a, b) __irshift__(self, other)
27<< Bitwise L shift a << b lshift(a, b) __lshift__(self, other)
1# Below follow the math operators that can be used in python
2# ** Exponent
32 ** 3 # Output: 8
4# % Modulus/Remaider
522 % 8 # Output: 6
6# // Integer division
722 // 8 # Output: 2
8# / Division
922 / 8 # Output: 2.75
10# * Multiplication
113 * 3 # Output: 9
12# - Subtraction
135 - 2 # Output: 3
14# + Addition
152 + 2 # Output: 4
1# Below follow the comparison operators that can be used in python
2# == Equal to
342 == 42 # Output: True
4# != Not equal to
5'dog' != 'cat' # Output: True
6# < Less than
745 < 42 # Output: False
8# > Greater Than
945 > 42 # Output: True
10# <= Less than or Equal to
1140 <= 40 # Output: True
12# >= Greater than or Equal to
1339 >= 40 # Output: False
1>>> s1 = {"a", "b", "c"}
2>>> s2 = {"d", "e", "f"}
3
4>>> # OR, |
5>>> s1 | s2
6{'a', 'b', 'c', 'd', 'e', 'f'}
7>>> s1 # `s1` is unchanged
8{'a', 'b', 'c'}
9
10>>> # In-place OR, |=
11>>> s1 |= s2
12>>> s1 # `s1` is reassigned
13{'a', 'b', 'c', 'd', 'e', 'f'}
14