Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What does ^ do in python?

I’ve stumbled upon ^ operator in python, and I don’t understand what is does.
I couldn’t find anything about it online.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The ^ operator in Python is known as the bitwise XOR operator.
It performs a binary XOR operation on two operands and returns the result.

Let’s say you have two integers a and b, and you want to perform the XOR operation between them. The XOR operation returns 1 if the corresponding bits in the two integers are different, and 0 if they are the same.

a ^ b = 6 ^ 3 = 5

a = 110
b = 011
---------
    101 = 5
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading