(is) operator checks weather both variables are pointing to the same reference of an object
**For Integer data type:-**
a=10
b=10
a is b returns True
also id(a) and id(b) is same
**Same goes for string data type.**
**For Float data type:-**
a=2.5
b=2.5
a is b returns False
also id(a) and id(b) is different
And same goes for other datatypes except (int and str)
**Here is some interesting fact**
if
a=(1,2,3)
b=(1,2,3)
c=1
a is b returns False
id(a) and id(b) are different as I mentioned above.
but
id(c) and id(b[0]) is same.
also c is b[0] returns True.
[enter image description here][1]
[enter image description here][2][enter image description here][3]
[1]: https://i.stack.imgur.com/AGP3l.png
[2]: https://i.stack.imgur.com/yoM9v.png
[3]: https://i.stack.imgur.com/Q3uLe.png
Can anyone please help me understand why python shows this kind of behavior for (int and str)datatypes...