+ 2
What is ^ used for?
I tried doing 4^2 and got 6, then tried 6^2 and got 4? What does ^ do in Python if itâs not an exponential operator? Is it one at all? I canât find anything on google.
3 Answers
+ 3
oh i found out ^ is a bitwise xor operator so now im even more confused because i have no clue what that means. so if someone could baby that down for me lol id appreciate it
+ 2
It is xor operator.. It compares the corresponding binary digits of two binary numbers, if they are different then the answer is 1, if they are similar the answer become 0
4 in binary is 0100
2 in binary is 0010
6 in binary is 0110 (answer)
The same with the second example
6 in binary is 0110
2 in binary is 0010
4 in binary is 0100