Q
What is the difference between copy.copy and copy.deepcopy in Python?
-
A
deepcopy copies only references
-
B
copy.copy works only on strings
-
C
They are identical
-
D
copy.copy duplicates only the outer container; deepcopy recursively copies the nested objects as well
Correct Answer:
D. copy.copy duplicates only the outer container; deepcopy recursively copies the nested objects as well
Explanation:
With a shallow copy, nested mutable objects are still shared.