Which type of copy?

Report a typo

You found a machine that can copy objects. It is a device that takes an object and returns its copy. The problem is that you don't know if it creates a shallow copy or a deep copy. You should solve this problem.

To do this, write a function detect_copy() which takes no arguments. From this function, you should call the predefined function copying_machine(obj); it takes the passed object obj and returns either its shallow copy or its deep copy. The copying machine function makes only one type of copy, and your function should find this out and return "shallow copy" or "deep copy".

You do NOT need to read anything from the input, define obj for yourself. For example, it can be obj = [[1, 2], [3, 4]].

You can call copying_machine() in the following way: copy_obj = copying_machine(obj).

Tip: To find the type of copy you can use the id() function

Write a program in Python 3
import copy


def detect_copy():
pass
___

Create a free account to access the full topic