xor of binary numbers in python code example
Example: how to calculate binary AND, OR, XOR in python
>>> # this example swaps integers without a temporary variable using XOR
>>> a = 2
>>> b = 8
>>> a ^= b
>>> b ^= a
>>> a ^= b
>>> a
8
>>> b
2
>>> # this example swaps integers without a temporary variable using XOR
>>> a = 2
>>> b = 8
>>> a ^= b
>>> b ^= a
>>> a ^= b
>>> a
8
>>> b
2