Python MCQ Quiz Hub

Dictionary Python MCQ set 1

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

Keys of dictionary must be _______________





✅ Correct Answer: 2

Dictionaries in python are _______





✅ Correct Answer: 4

Which of the following is used to delete an element from Dictionary?





✅ Correct Answer: 1

Which statement is used to create an empty dictionary? a.





✅ Correct Answer: 1

Dictionary is a ___________ data type.





✅ Correct Answer: 2

Write the output of the following : d1 = {"a" : 50, "b" : 50} d2 = {"a" : 500, "b" : 50} print(d1 > d2)





✅ Correct Answer: 3

Key – value concept is in ____





✅ Correct Answer: 3

In dictionary Keys and values are separated by ________________





✅ Correct Answer: 1

All elements in dictionary are separated by _________





✅ Correct Answer: 2

Which of the following is an example of dictionary?





✅ Correct Answer: 3

1,2,3 are the ______________ in the following dictionary. D = {1 : “One”, 2 : “Two”, 3 : “Three”}





✅ Correct Answer: 1

Keys in dictionary are _____________ .





✅ Correct Answer: 1

What type of error is returned by the following code : a={'a' : "Apple", 'b' : "Banana" , 'c' : "Cat"} print(a[1])





✅ Correct Answer: 1

Write the output of the following code : a={'a' : "Apple", 'b' : "Banana" , 'c' : "Cat"} a['a']="Anar" print(a)





✅ Correct Answer: 1

Traversing a dictionary can be done using ____________





✅ Correct Answer: 2

The following code will return data as ______________





✅ Correct Answer: 1

Write the output of the following code : A = {1 : "One", 2 : "Two", 3 : "Three"} B = {'A' : "Apple", 'B' : "Bat", 'C' : "Cat", 'D' : "Doll"} A.update(B) #print(B.values()) print(B)





✅ Correct Answer: 1

Write the output of the following code : A = {1 : "One", 2 : "Two", 3 : "Three"} B = {'A' : "Apple", 'B' : "Bat", 'C' : "Cat", 'D' : "Doll"} print(A.get(4,"Key Not Found"))





✅ Correct Answer: 2

Write the output of the following: A = {1 : "One", 2 : "Two", 3 : "Three"} B = {'A' : "Apple", 'B' : "Bat", 'C' : "Cat", 'D' : "Doll"} for i in A: print(i)





✅ Correct Answer: 1

Which statement is not correct in reference to the following code? A = {1 : "One", 2 : "Two", 3 : "Three"} A[4] = "Four"





✅ Correct Answer: 3

The following code is an example of _______ N = {A: {'name': 'Ravi', 'age': '5', 'sex': 'M'}, B: {'name': 'Golu', 'age': '2', 'sex': 'F'}}





✅ Correct Answer: 2

pop( ) function delete and ____ the element of dictionary.





✅ Correct Answer: 2

Which of the following is not method of dictionary?





✅ Correct Answer: 3

Write the output of the following code : A = {1 : "One", 2 : "Two", 3 : "Three"} print(A[2] + A[1])





✅ Correct Answer: 2

_______ datatype fall under mapping





✅ Correct Answer: 3

The key-value pair in dictionary is called ____





✅ Correct Answer: 1

Choose the correct statement Assertion (A) : Items in dictionaries are unordered. Reason (R) : We may not get back the data in the same order in which we had entered the data initially in the dictionary.





✅ Correct Answer: 4

_______ is the suitable data type for keys of dictionary in python.





✅ Correct Answer: 4

Choose the correct statement : Statement A : Dictionaries are mutable. Statement B : Contents of the dictionary can not changed after it has been created





✅ Correct Answer: 4

Write the output of the following : A = {1 : "One", 2 : "Two", 3 : "Three"} print("One" in A)





✅ Correct Answer: 2

_________ function returns the number of key: value pairs of the dictionary.





✅ Correct Answer: 2

Which of the following function create a dictionary from a sequence of key-value pairs





✅ Correct Answer: 2

Following statement return values in the form of _______ >>> D1.keys() #D1 is a dictionary





✅ Correct Answer: 2

Which of the following is feature of Dictionary?





✅ Correct Answer: 4

Which of the following is feature of Dictionary?





✅ Correct Answer: 4

Which of the following is feature of Dictionary?





✅ Correct Answer: 4

Which of the following is feature of Dictionary?





✅ Correct Answer: 4

Which of the following is feature of Dictionary?





✅ Correct Answer: 4

A = {“A” : “Apple”, “B” : “Ball”, “C” : “Cat”} Which of the following statement will return : dict_items([(‘A’, ‘Apple’), (‘B’, ‘Ball’), (‘C’, ‘Cat’)])





✅ Correct Answer: 3

Which of the following are immutable data type? a. String b. Tuple c. List d. Dictionary





✅ Correct Answer: 3

_________ function returns the value corresponding to the key passed as the argument.





✅ Correct Answer: 1

Write the output of the following : A = {"A" : "Apple", "B" : "Ball", "C" : "Cat"} print(A.get("D"))





✅ Correct Answer: 4

Which function helps to merge dictionary ‘D1’ and ‘D2’?





✅ Correct Answer: 3