Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

what does ^ do python

# This is a binary XOR
True ^ True # = False, as expected for xor

# For integers it's more complicated.  First we change the integers to
# binary.  Then we take each column one at a time and do xor on them.
8 ^ 3 # = 11.


"""
1000  # 8 (binary)
0011  # 3 (binary)
----  # APPLY XOR to each column
1011  # result = 11 (binary)
"""
Source by getridbug.com #
 
PREVIOUS NEXT
Tagged: #python
ADD COMMENT
Topic
Name
4+7 =