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

🚀 I'm Diwas Pandey, a Computer Engineer with an unyielding passion for Artificial Intelligence, currently pursuing a Master's in Computer Science at Washington State University, USA. As a dedicated blogger at AIHUBPROJECTS.COM, I share insights into the cutting-edge developments in AI, and as a Freelancer, I leverage my technical expertise to craft innovative solutions. Join me in bridging the gap between technology and healthcare as we shape a brighter future together! 🌍🤖🔬

View all posts by Diwas →


  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. Required fields are marked *