Answer to Question #169228 in Python for Paul Carpenter

Question #169228

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.


Describe the relationship between objects, references, and aliasing. Again, create your own examples with Python lists.


Finally, create your own example of a function that modifies a list passed in as an argument. Describe what your function does in terms of arguments, parameters, objects, and references.


Create your own unique examples for this assignment. Do not copy them from the textbook or any other source.


1
Expert's answer
2021-03-05T16:22:54-0500

a) The difference between the objects and values are listed below-

Objects: It is the instance of class. "is" operator is used to differentiate between two objects.

Values: It is an object which is used to assign a variable. We use == operator to determine the two variables are equal or not, it is equal then it return true.

list1=['abc','def','ghi','jkl']
list2=list1
list3=list(list1)
print(list1);
print(list2);
print(list3);
print(list1==list2);
print(list2==list3)
print(list1==list3)
print(list1 is list2)
print(list2 is list3)
print(list1 is list3)

Aliasing: Variables refers to the same identifiers refers to the same variables. It acts as a point

Objects: An objects are instance of classes.


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