CBSE Class 11 Informatics Practices Question 28 of 66

Dictionary — Question 11

Back to all questions
11
Question

Question 11

Consider the given code:

D1={1: 'India', 2: 'Russia', 3: 'World'}
D2={'School' : 'EOIS' , 'Place ' : 'Moscow'}
print(D1.update (D2) )

What will be the output of the above code:

  1. None
  2. {1: 'India' , 2: 'Russia' , 3: 'World' , 'School' : 'EOIS' , 'Place' : 'Moscow'}
  3. Error
  4. None of these
Answer

None

Reason — The output is "None" when using print(D1.update(D2)) because the update() method for dictionaries modifies the dictionary in place. It does not return the updated dictionary itself; instead, it returns "None".