CBSE Class 11 Computer Science Question 31 of 112

Dictionaries — Question 11

Back to all questions
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.

  1. key copy
  2. shallow copy
  3. deep copy
  4. partial copy
Answer

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'}