# How Do You Get The Logical xor Of Two Variables In Python?

In this tutorial, we will discuss How do you get the logical xor of two variables in Python where we know that XOR (exclusive or) uses ‘^’ operator to perform XOR between two variables. Now here we will perform this operation over two variables and try to find the result.

### Logical Operator

There are different Logical operators which we can perform on our data or two variables and there is one of the most used operators XOR that we are going to discuss here how it works and how to use it on our two variables and what will be the result of it.

#### XOR

Xor operator works on the binary representation of the value that we provide so the machine first convert the given value into binary. As it is a regular task for a machine to convert a number we have given into binary and then perform operations.

But in the case of logical operations, we perform all the operations on the binary representations so there is no need to again convert the binary number into decimal for getting the result we simply perform the operations and revert with the result as decimal.

To perform the same we do not need to take anything for converting the variable number in to binary it will do automatically and perform what we want.

To understand it in a better way follow the example given below and execute the xor operator.

```a = True
b = False

result = a ^ b

print(result) # Output: True
```

Here we perform the xor operator on two variables a and b where the value of a is true which is considered as 1 whereas b has a value as false which means 0 and the result of it will be true which means 1.