10 AnswersNew Answer
This is "^" an assignment operator in Python. It is used to perform Bitwise XOR on the operands and then assigning result to the left operand. https://code.sololearn.com/cqI8ecK0sEOE/?ref=app Also, look at this, (from Bahha🐧 ) [ how the result is calculated? 5^3 = 6 And the others] ^ is for xor you have to think of numbers as binary. that's why they are called bitwise operators. in xor if you get the same digit you get 0 example. 0 ^ 0 = 0 1 ^ 1 = 0 0 ^ 1 = 1 1 ^ 0 = 1 in your example read them vertically 5 = 00000101 xor ^ 3 = 00000011 = = 00000110 00000110 binary = 6 decimal
DiMasik23_ "**" is an arithmetic operator and it is used for exponentiation in Python. But we use "^" as Bitwise operator and it is not used for exponentiation. "^" not defined for exponentiation in Python. As I know, "^" defined for exponentiation in R. Thanks for understanding. Happy coding!
This is coz of bitwise xor operator https://www.geeksforgeeks.org/python-bitwise-operators/amp/
mesarthim what do you mean by "^" Is an assignment operator? And don't we perform bitwise right shift using ">>" operator ? Sorry if i asked something stupid but just clearing my doubts.
Abhay ">>" also using for shifting but in Python, there is a special sign its name is "Bitwise XOR". The sign looks the visualization binary expansions of the variables and does some calculations in binary dimension. I hope, it's clear enough. Also, don't think that it's stupid, I can be wrong or mix something. So, asking is the best choice. :)
Thanks mesarthim, now I understand this
Abhay, No problem 🙂, my problem solved. Thanks 😀
HrCoder, this link is very helpful, thanks 🙂
Use "**" operator. If i think right, it have to help you.
DiMasik23_ I knew it. ** means power. By the way thanks 🙂