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.
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.
Comments
Leave a comment