11
Question Question 11
A copy of the dictionary where only the copy of the keys is created for the new dictionary, is called ............... copy.
- key copy
- shallow copy
- deep copy
- partial copy
shallow copy
Reason — Shallow copy means the content of the dictionary is not copied by value, but just creating a new reference. It is done by using copy() function on original dictionary.
For example:
original_dict = {1:'computer with python', 2:'computer with java'}
new_dict = original_dict.copy()
print(new_dict)Output
{1: 'computer with python', 2: 'computer with java'}