KnowledgeBoat Logo
|

Computer Science

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

Python Dictionaries

2 Likes

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

Answered By

1 Like


Related Questions