PYTHON IDENTIFY OPERATORS
PYTHON IDENTIFY OPERATORS compare two values and return TRUE if they are equal. Otherwise PYTHON will return FALSE.
There are two IDENTIFY OPERATORS in PYTHON.
1. IS
2. IS NOT
IS IDENTIFY OPERATOR
It returns TRUE if both the values are equal. Otherwise it will return FLASE.
# Identity operator example
a = 9
b = 9
print("\nValue of a ->", a)
print("\nValue of b ->", b)
print("\na equals to b :", a is b)
PYTHON IDENTIFY OPERATORS : Output
Value of a -> 9
Value of b -> 9
a equals to b : True
Now we are changing the value of b to see the impact.
# Identity operator example
a = 9
b = 5
print("\nValue of a ->", a)
print("\nValue of b ->", b)
print("\na equals to b :", a is b)
PYTHON IDENTIFY OPERATORS : Output
Value of a -> 9
Value of b -> 5
a equals to b : False
IS NOT IDENTIFY OPERATOR
Identity Operator returns TRUE if both the values are not equal. Otherwise it will return FLASE.
# Identity operator example
a = 9
b = 5
print("\nValue of a ->", a)
print("\nValue of b ->", b)
print("\na is not equals to b :", a is not b)
PYTHON IDENTIFY OPERATORS : Output
Value of a -> 9
Value of b -> 5
a is not equals to b : True
Now we are changing the value of b to 9 same as a to see the impact.
# Identity operator example
a = 9
b = 9
print("\nValue of a ->", a)
print("\nValue of b ->", b)
print("\na is not equals to b :", a is not b)
PYTHON IDENTIFY OPERATORS : Output
Since both a and b have the same value, the IS NOT OPERATOR returns FALSE.
RELATED TOPICS: