📑 Task
1) Can you explain difference between the follow objects:x_same, x_copy, x_equal?
2) Write a function that compares two lists based on the following parameters:
a) is the list length the same,
b) do all unique elements match,
c) whether the composition of the list as a whole is the same,
d) are the elements arranged in the same order,
e) whether they have the same address in memory.
Apply it to the indicated objects
📑 Answer
1) a) x_same and x contain from the same elements,but they are different and independent objects
b) x_equal refers to the same list object as x,
so they share the same memory address
c) x_copy refers to a new list object created by making
a shallow copy of x, so x_copy is a different object
with the connection to the original list because of
the nested mutable component []
2)
No comments:
Post a Comment