Python Free Tutorial

Identity operator in python are used to check the object identity of two operands which doesn’t mean equality (==). We use ‘is’ and ‘is not’ operator. Actually, Identity operators compare the same operands with same memory locations. Two variables that are equal does not imply that they are identical. Lets understand it with example:

>>> a = 5
>>> b = 5
>>> print ("a is b :",a is b, "  a == b :", a==b)
>>> c = {5,4}
>>> d = {5,4}
>>> print ("c is d :",c is d, "  c == d :", c==d)
>>> print ('c is not d :', c is not d)

a is b : True   a == b : True
c is d : False   c == d : True
c is not d : True

In the above example, we see that a and b are integers of same values, so they are equal as well as identical. But c and d are sets. They are equal but not identical. It is because interpreter locates them separately in memory although they are equal in identity operator in python.

This page is contributed by Diwas & Sunil . If you like AIHUB and would like to contribute, you can also write an article & mail your article to . See your articles appearing on AI HUB platform and help other AI Enthusiast.

About Diwas Pandey

Highly motivated, strong drive with excellent interpersonal, communication, and team-building skills. Motivated to learn, grow and excel in Data Science, Artificial Intelligence, SEO & Digital Marketing

View all posts by Diwas Pandey →


  1. Attractive section of content. I just stumbled upon your website and in accession capital to assert that I get in fact enjoyed account your blog posts.
    Any way I will be subscribing to your feeds and even I achievement you access consistently rapidly.

Leave a Reply

Your email address will not be published.