Answer to Question #282087 in Python for kika

Question #282087

Describe the difference between objects and values using the terms “equivalent” and “identical”. Illustrate the difference using your own examples with Python lists and the “is” operator.


1
Expert's answer
2021-12-22T14:18:18-0500

Object is an instance of a class while value is an object that assigns to a variable. “is” operator is used to test object identity while equivalent operator is used to test the identity of the object based on its values. “is” operator is used to know if two objects are equal or not while equivalent (==) is used to know if two operands are equal of not.

Example


l1 = [1,2,3]
l2 = [1,2,3]
if (l1 == l2):
    print("True")
else:
    print("False")
if (l1 is l2):
    print("True")
else:
    print("False")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS