";require "../templates/head_jq_bs4.php";echo "";$img_path="..";require "templates/top_bs4.php"; echo "

is , not is ( Identity Operators)

";require "templates/body_start.php";?>
x is y
x, y : input objects
Return boolean value True or False. Returns True if both side operands are of same identity, otherwise False

x is not y
x, y : input objects
Return boolean value True or False. Returns True if both side operands are NOT of same identity, otherwise False
a=30b=30 print(a is b ) # True a=300b=300 print(a is b ) # False
Why the second print() returns False ?
Identity of the object changed in second case ( Why ?) . (For integer -5 to 256, id will not change.).
By using is we are checking the identity of the object Not the Value so we got False in second case ( Identity remain same for integers between -5 and 256 )

Difference between id and value

Our is operator checks the identity only , not the value of the object.
Example 1
a=-6b=-6print("Using is :",a is b) print("using == :",a==b)
Output
Using is : Falseusing == : True
Example 2
a=30b=30 print(a is b ) # True a=300b=300 print(a is b ) # Falseprint(a == b ) # True

Using type of the object

x=500print(type(x) is int) # True
Using float
x=100.34print(type(x) is int)  # False
x=100.34print(type(x) is float) # True
x=30y=400print(type(x) is type(y)) # True

Using list

More on list

Example
my_list1=[1,2,3]my_list2=[4,5,6]print(type(my_list1) is type(my_list2)) # True
Using frozenset()
my_list1=[1,2,3]my_list2=frozenset([4,5,6])print(type(my_list1) is type(my_list2)) # False
Using boolean
x=Truey=Falseprint(type(x) is type(y)) # True

Example using is not

x=56.78y=100print((x  is not y)) # True

All Python Operators
in and not in: The Membership operators id() Iterator any() type()