60+ Dictionary Python Best MCQ Class 11

Share with others

Dictionary Python MCQ

DICTIONARY PYTHON
DICTIONARY PYTHON

Q1. Keys of dictionary must be _______________

a. antique

b. unique

c. mutable

d. integers

Q2. Dictionaries in python are _________________.

a. Mutable data type

b. Non-Mutable data type

c. Mapping data type

d. Both a and c

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

a. pop( )

b. delete

c. remove

d. None of the above

Q4. We can repeat the values of Key in Dictionary?

a. True

b. False

Q5. clear() method is used to delete the dictionary.

a. True

b. False

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

a. d1 = { }

b. d1 = ( )

c. d1 = dict{ }

d. d1 = [ ]

Q7. Dictionary is a ___________ data type.

a. Sequence

b. Mapping

c. Ordered

d. None of the above

Q8. Dictionaries are flexible in nature, means elements can be added or removed from it.

a. True

b. False

Q9. Write the output of the following :

d1 = {"a" : 50, "b" : 50}
d2 = {"a" : 500, "b" : 50}
print(d1 > d2)

a. True

b. False

c. Error

d. None of the above

Q10. Only values (without keys) can be printed in dictionary?

a. True

b. False

Dictionary Python MCQ

DICTIONARY PYTHON
DICTIONARY PYTHON

Click here to check your performance on Dictionary Python MCQ

Dictionary Python MCQ

Q11. Key – value concept is in _______________

a. List

b. String

c. Dictionary

d. Tuple

Q12. In dictionary Keys and values are separated by ________________

a. Colon (:)

b. Comma( ,)

c. Semicolon(;)

d. dot(.)

Q13. All elements in dictionary are separated by _________

a. Colon (:)

b. Comma( ,)

c. Semicolon(;)

d. dot(.)

Q14. Both keys and values are unique in dictionary.

a. True

b. False

Q15. Which of the following is an example of dictionary?

a. L = [ ]

b. C = ( )

c. D = { }

d. None of the above

Q16. 1,2,3 are the ______________ in the following dictionary.

D = {1 : “One”, 2 : “Two”, 3 : “Three”}

a. Keys

b. Values

c. Items

d. None of the above

Q17. Keys in dictionary are _____________ .

a. Mutable

b. Immutable

c. antique

d. integers

Q18. What type of error is returned by the following code :

a={'a' : "Apple", 'b' : "Banana" , 'c' : "Cat"}
print(a[1])

a. KeyError

b. KeyNotFoundError

c. NotFoundError

d. Syntax Error

Q19. Write the output of the following code :

a={'a' : "Apple", 'b' : "Banana" , 'c' : "Cat"}
a['a']="Anar"
print(a)

a. {‘a’: ‘Anar’, ‘b’: ‘Banana’, ‘c’: ‘Cat’}

b. Error

c. {‘a’ : “Apple, ‘a’: ‘Anar’, ‘b’: ‘Banana’, ‘c’: ‘Cat’}

d. None of the above

Q20. Traversing a dictionary can be done using ____________

a. if statement

b. loop

c. jump statement

d. None of the above

Dictionary Python MCQ

DICTIONARY PYTHON
DICTIONARY PYTHON

Click here to check your performance on Dictionary Python MCQ

Dictionary Python MCQ

Q21. The following code will return data as ______________

a. List

b. Tuple

c. Dictionary

d. None of the above

Q22. 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)

a. {‘A’ : ‘Apple’ , ‘B’ : ‘Bat’ , ‘C’ : ‘Cat’ , ‘D’ : ‘Doll’}

b. {1 : “One” , 2 : “Two” , 3 : “Three”}

c. {1: ‘One’ , 2: ‘Two’ , 3: ‘Three’ , ‘A’: ‘Apple’ , ‘B’: ‘Bat’ , ‘C’: ‘Cat’ , ‘D’: ‘Doll’}

d. None of the above

Q23. 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"))

a. KeyError

b. Key Not Found

c. None

d. Syntax Error

Q24. 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)
a. 

1
2
3
b. 

1
2
3

c. {1 : “One”, 2 : “Two”, 3 : “Three”}

d. None of the above

Q25. Which statement is not correct in reference to the following code?

A = {1 : "One", 2 : "Two", 3 : "Three"}
A[4] = "Four"

a. It will add value at the end of dictionary.

b. It will modify value if the key already exist.

c. It will add value in between of the dictionary.

d. All of the above

Q26. There is no index value in dictionary like we have in List.(T/F)

a. True

b. False

Q27. The following code is an example of _______

N = {A: {'name': 'Ravi', 'age': '5', 'sex': 'M'}, B: {'name': 'Golu', 'age': '2', 'sex': 'F'}}

a. Normal Dictionary

b. Nested Dictionary

c. Empty Dictionary

d. All of the above

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

a. display

b. return

c. not return

d. add

Q29. Which of the following is not method of dictionary?

a. len( )

b. pop( )

c. del ( )

d. update( )

Q30. Write the output of the following code :

A = {1 : "One", 2 : "Two", 3 : "Three"}
print(A[2] + A[1])

a. Error

b. TwoOne

c. 21

d. {1 : “One”, 2 : “Two”, 3 : “Three”}

Dictionary Python MCQ

DICTIONARY PYTHON
DICTIONARY PYTHON

Click here to check your performance on Dictionary Python MCQ

Dictionary Python MCQ

Q31. _________ datatype fall under mapping.

a. List

b. Tuple

c. Dictionary

d. String

Q32. The key-value pair in dictionary is called _________.

a. item

b. pair item

c. paired value

d. value

Q33. 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.

a. A is true but R is false

b. A is false but R is true

c. Both A and R are false

d. Both A and R are true and R is the correct explanation of A

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

a. Number

b. String

c. Tuple

d. All of the above

Q35. Choose the correct statement :

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

a. Statement A is True

b. Statement B is True

c. Both the statements are True

d. Statement A is True and Statement B is False

Dictionary Python MCQ

Q36. Write the output of the following :

A = {1 : "One", 2 : "Two", 3 : "Three"}
print("One" in A)

a. True

b. False

c. Error

d. One

Q37. Write the output of the following :

A = {"A" : "Apple", "B" : "Ball", "C" : "Cat"}
print(A in A)

a. True

b. False

c. Error

d. A

Q38. ___________ function returns the number of key: value pairs of the dictionary.

a. total( )

b. len( )

c. length( )

d. items( )

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

a. dictionary( )

b. dict( )

c. create( )

d. convert( )

Q40. Following statement return values in the form of _______

>>> D1.keys() #D1 is a dictionary

a. tuple

b. list

c. string

d. dictionary

Dictionary Python MCQ


Click here to check your performance on Dictionary Python MCQ

Dictionary Python MCQ

Q41. Which of the following is feature of Dictionary?

a. Keys are unique within a dictionary.

b. Keys must be of an immutable data type.

c. Dictionary is mutable.

d. All of the above

Q42. A = {“A” : “Apple”, “B” : “Ball”, “C” : “Cat”}

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

a. print(A.keys( ))

b. print(A.values( ))

c. print(A.Items( ))

d. print(A.get( ))

Q43. Which of the following are immutable data type?

a. String
b. Tuple
c. List
d. Dictionary

a. a and c

b. b and d

c. a and b

d. c and d

Q44. __________ function returns the value corresponding to the key passed as the argument.

a. get( )

b. values( )

c. update( )

d. del( )

Q45. Write the output of the following :

A = {"A" : "Apple", "B" : "Ball", "C" : "Cat"}
print(A.get("D"))

a. KeyNotFoundError

b. Name Error

c. Type Error

d. None

Dictionary Python MCQ

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

a. merge( )

b. append( )

c. update( )

d. get( )

Q47. Which function/statement delete the dictionary from the memory?

a. clear( )

b. del

c. delete( )

d. pop( )

Q48. Which function/statement delete all the items of the dictionary?

a. clear( )

b. del

c. delete( )

d. pop( )

Q49. Choose the correct statement, in reference to the following code:

D1.update(D2) #D1 and D2 are dictionaries

a. It will merge all the elements of dictionary ‘D1’ in dictionary ‘D2’.

b. It will merge all the elements of dictionary ‘D2’ in dictionary ‘D1’.

c. It will create a new dictionary.

d. None of the above

Q50. Write a statement to retrieve the value corresponding to the key 7 in dictionary ‘D1’.

a. D1.get(7)

b. D1.values(7)

c. D1.pop(7)

d. D1.disp(7)

Dictionary Python MCQ


Click here to check your performance on Dictionary Python MCQ

Dictionary Python MCQ

Q51. Write the output of the following:

A = {"A" : "Apple", "B" : "Ball", "C" : "Cat"}
print(A.pop("C"))

a. Error

b. None

c. Cat

d. {‘A’: ‘Apple’, ‘B’: ‘Ball’}

Q52. Aman wants to convert the sequence given below to dictionary. Which of the following function will help him to convert?

((1,”Amit”),(2,”Suman”),(3,”Ravi”))

a. dict( )

b. dictionary( )

c. tuple( )

d. convert( )

Q53. Write the output of the following:

D={1: 'Amit', 2: 'Suman', 3: 'Ravi', 4: 'Anuj'}
print(max(D.values()))

a. Amit

b. Suman

c. Ravi

d. Error

Q54. Write the output of the following:

D={1: 'Amit', 2: 'Suman', 3: 'Ravi', 4: 'Anuj'}
print(D.get(3))

a. Amit

b. Suman

c. Ravi

d. Anuj

Q55. Which of the statement will delete third item (3: ‘Ravi’) from dictionary given below:

D={1: ‘Amit’, 2: ‘Suman’, 3: ‘Ravi’, 4: ‘Anuj’}

a. D.pop(3)

b. del D[3]

c. Both of the above

d. D.clear(3)

Q56. Write the output of the following :

D={1: 'Amit', 2: 'Suman', 3: 'Ravi', 4: 'Anuj'}
print(tuple(D))

a. ((1,”Amit”, (2, “Suman”), (3, “Ravi”), (4, “Anuj”))

b. (1, 2, 3, 4)

c. (“Amit”, “Suman”, “Ravi”, “Anuj”)

d. None of the above

Q57. 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’}

a. print(D.get(3))

b. print(D[3])

c. Both of the above

d. None of the above

Q58. 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])

a. 34

b. 45

c. m

d. Suman

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

a. Mathematical Operator

b. Relational Operator

c. Membership Operator

d. Logical Operator

Q60. Write the output of the following:

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

a. True

b. False

c. Error

d. None of the above

Dictionary Python MCQ


Click here to check your performance on Dictionary Python MCQ

Dictionary Python MCQ

Q61. 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.

a. D1.update(D2)

b. D2.update(D1)

c. D1.append(D2)

d. D2.append(D1)

Q62. 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.

a. D = {“Jan” : 31, “Feb” : 28, “Mar” : 31}

b. D = [“Jan”:31, “Feb”:28, “Mar”:31]

c. D = {“Jan” ; 31, “Feb” ; 28, “Mar” ; 31}

d. D = (“Jan”:31, “Feb”:28, “Mar”:31)

Dictionary Python MCQ


Important Links

100 Practice Questions on Python Fundamentals

120+ MySQL Practice Questions

90+ Practice Questions on List

50+ Output based Practice Questions

100 Practice Questions on String

70 Practice Questions on Loops

120 Practice Questions of Computer Network in Python

70 Practice Questions on if-else

40 Practice Questions on Data Structure

Computer Science Syllabus 2021-2022.

Informatics Practices Syllabus 2021-2022

Class 12 Computer Science Chapter wise MCQ


Share with others

Leave a Reply

error: Content is protected !!