Bit-wise Operators

Bitwise operators treat the operands strings of binary digits.

x = 70            # 70 = 1000110
y = 23            # 23 = 0010111
z = 0
z = x & y        # Binary AND
print (f"Binary AND, z = { z }")
z = x | y       # Binary OR
print (f"Binary OR, z = { z }")
z = x ^ y        # Binary XOR
print (f"Binary XOR, z = { z }")
z = ~x          # Binary Ones Complement
print (f"inary Ones Complement, z = { z }")
z = x << 2      # Binary Left Shift
print (f"Binary Left Shift, z = { z }")
z = x >> 2      # Binary Right Shift
print (f"Binary Right Shift, z = { z }")