Today, We want to share with you xor in python.In this post we will show you logical and bitwise operators in python, hear for xnor in python we will give you demo as well as example for implement.In this post, we will learn about python wait 5 seconds with an example.
How do you get the logical xor of two variables in Python?
so you can use a XOR, also known as “exclusive or”, compares two binary numbers bitwise. If both bits are the same, XOR results 0.
If the bits are different, XOR results 1.
For instance, easy to like as performing XOR on 6 as well as 3 (binary 110 and 011, respectively) results in 5 (binary 101).
USE THE XOR OPERATOR ^ TO PERFORM THE “EXCLUSIVE OR” OPERATION
lat’s start Use the XOR operator ^ between two main values to perform bitwise “exclusive or” on their binary data representations.
When used between two integers, the XOR operator returns an integer.
Example 1: Compare 110 and 011
results = 6 ^ 3 print(results)
When step by step performing XOR on two booleans,
True is treated as 1 value, as well as
False is treated as 0 value.
So you can XOR between two booleans returns a boolean.
Example 2: Compare 1 and 0
results = True ^ False print(results)
I hope you get an idea about bitwise left and right shift operator in python.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.