Computer Science - Class 12
Solutions to CBSE Sample Paper - Computer Science Class 12

Given the following dictionaries

dict_exam={"Exam":"AISSCE", "Year":2023}

dict_result={"Total":500, "Pass_Marks":165}

 

Which statement will merge the contents of both dictionaries?

a. dict_exam.update(dict_result)

b. dict_exam + dict_result

c. dict_exam.add(dict_result)

d. dict_exam.merge(dict_result)

 

Answer:

The update( ) method is used to merge one dictionary into another in python.

Checking the options:

  • (a) dict_exam.update(dict_result)

(a) dict exam update dict result -Teachoo.png

  • (b) dict_exam + dict_result 

(b) dict exam + dict result -Teachoo.png

  • (c) dict_exam.add(dict_result)

(c) dict exam add dict result -Teachoo.png

  • (d) dict_exam.merge(dict_result)

(d) dict exam merge(dict result) -Teachoo.png

So, the correct answer is (a).

Go Ad-free
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science, Social Science, Physics, Chemistry, Computer Science at Teachoo.