We use identity operators to compare the memory location of two objects.
Operator | Syntax | Description |
---|---|---|
is | x is y | This returns True if both variables are the same object |
is not | x is not y | This returns True if both variables are not the same object |
Example
Use the operators to evaluate the following.
Qn | Equation | True or False? |
---|---|---|
1 |
x = 200 |
True or False |
2 | x = 200 y = 500 z = y print(x is not y) |
True or False |