Python MCQ Quiz Hub

Dictionary Python MCQ set 2

Choose a topic to test your knowledge and improve your Python skills

Anshu created two dictionaries “D1” and “D2” in python. Later on she wants to add all the elements of D2 in D1. As a friend of Anshu, help her to write the code.





✅ Correct Answer: 1

Dhriti wants to create a dictionary with “Jan”, “Feb”, “Mar” as key and 31, 28, 31 as values respectively. Help her to write the correct code.





✅ Correct Answer: 1

Write the output of the following: D={1: ['Amit',23,21], 2: ['Suman',45,34], 3: 'Ravi', 4: 'Anuj'} print("Amit" in D)





✅ Correct Answer: 2

Which operator is used to check if the key is present in the dictionary or not?





✅ Correct Answer: 3

Write the output of the following: D={1: ['Amit',23,21], 2: ['Suman',45,34], 3: 'Ravi', 4: 'Anuj'} m = D.get(2) print(m[2])





✅ Correct Answer: 1

Parth wants to display the value corresponding to the key “3” in dictionary given below. As a friend of Parth, help him to find the correct code.D={1: ‘Amit’, 2: ‘Suman’, 3: ‘Ravi’, 4: ‘Anuj’}





✅ Correct Answer: 3

Write the output of the following : D={1: 'Amit', 2: 'Suman', 3: 'Ravi', 4: 'Anuj'} print(tuple(D))





✅ Correct Answer: 2