+ 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.

14th Oct 2019, 1:21 AM
꧁༺ Jenspi ༻꧂
꧁༺ Jenspi ༻꧂ - avatar
3 Respuestas
14th Oct 2019, 4:40 AM
Diego
Diego - avatar
+ 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
14th Oct 2019, 1:26 AM
꧁༺ Jenspi ༻꧂
꧁༺ Jenspi ༻꧂ - avatar
+ 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
14th Oct 2019, 1:32 AM
Ruba Kh
Ruba Kh - avatar