Skip to main content

Dictionary In Python — Part 1 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Dictionary In Python — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/40 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 40
★ FPSC ★ PPSC

What is the purpose of the popitem() method for dictionaries?

Question 2 of 40
★ FPSC ★ PPSC

What is the output of the following code: my_dict = {'a': 1, 'b': 2} my_dict.popitem() print(my_dict)

Question 3 of 40
★ FPSC ★ PPSC

Which of the following data types in Python is used to store key-value pairs?

Question 4 of 40
★ FPSC ★ PPSC

What method is used to check if a key exists in a dictionary, and if not, add it with a default value?

Question 5 of 40
★ FPSC ★ PPSC

What does the len() function do when applied to a dictionary?

Question 6 of 40
★ FPSC ★ PPSC

In Python, how can you get a list of all key-value pairs in a dictionary?

Question 7 of 40
★ FPSC ★ PPSC

What is the purpose of the dict() constructor in Python?

Question 8 of 40
★ FPSC ★ PPSC

Which method is used to remove a key-value pair from a dictionary?

Question 9 of 40
★ FPSC ★ PPSC

In Python, how can you check if a key exists in a dictionary?

Question 10 of 40
★ FPSC ★ PPSC

What method is used to update the values of a dictionary with the values from another dictionary?

Question 11 of 40
★ FPSC ★ PPSC

What is the purpose of the keys() method for dictionaries?

Question 12 of 40
★ FPSC ★ PPSC

Which method is used to get a list of all values in a dictionary?

Question 13 of 40
★ FPSC ★ PPSC

In Python, how can you remove all key-value pairs from a dictionary?

Question 14 of 40
★ FPSC ★ PPSC

What is the purpose of the items() method for dictionaries?

Question 15 of 40
★ FPSC ★ PPSC

Which method is used to create a shallow copy of a dictionary?

Question 16 of 40
★ FPSC ★ PPSC

What is the purpose of the clear() method for dictionaries?

Question 17 of 40
★ FPSC ★ PPSC

What is the purpose of the fromkeys() method for dictionaries?

Question 18 of 40
★ FPSC ★ PPSC

In Python, how can you get a list of all keys in a dictionary?

Question 19 of 40
★ FPSC ★ PPSC

What is the output of the following code: my_dict = {'a': 1, 'b': 2} print(my_dict['a'])

Question 20 of 40
★ FPSC ★ PPSC

How can you add a new key-value pair to a dictionary in Python?

Question 21 of 40
★ FPSC ★ PPSC

In Python, how can you create an empty dictionary?

Question 22 of 40
★ FPSC ★ PPSC

What is the purpose of the values() method for dictionaries?

Question 23 of 40
★ FPSC ★ PPSC

What will be the output of the following code: my_dict = {'a': 1, 'b': 2} my_dict['c'] = 3 print(my_dict)

Question 24 of 40
★ FPSC ★ PPSC

What is the output of the following code: my_dict = {'a': 1, 'b': 2, 'c': 3} my_dict.pop('b') print(my_dict)

Question 25 of 40
★ FPSC ★ PPSC

What is the output of the following code: my_dict = {'a': 1, 'b': 2, 'c': 3} print(my_dict.get('d', 0))

Question 26 of 40
★ FPSC ★ PPSC

What is the output of the following code: my_dict = {'a': 1, 'b': 2, 'c': 3} my_dict.values() print(my_dict)

Question 27 of 40
★ FPSC ★ PPSC

What will be the output of the following code: my_dict = {'a': 1, 'b': 2, 'c': 3} my_dict.items() print(my_dict)

Question 28 of 40
★ FPSC ★ PPSC

What is the output of the following code: my_dict = {'a': 1, 'b': 2} del my_dict['b'] print(my_dict)

Question 29 of 40
★ FPSC ★ PPSC

What is the output of the following code: my_dict = {'a': 1, 'b': 2} new_dict = my_dict.copy() print(new_dict)

Question 30 of 40
★ FPSC ★ PPSC

What will be the output of the following code: keys = ['a', 'b', 'c'] values = 0 my_dict = dict.fromkeys(keys, values) print(my_dict)

Question 31 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? >>> import collections >>> a=collections.OrderedDict((str(x),x) for x in range(3)) >>> a

Question 32 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? >>> a={} >>> a.fromkeys([1,2,3],"check")

Question 33 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? d1 = {"john":40, "peter":45} d2 = {"john":466, "peter":45} d1 == d2

Question 34 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? d = {"john":40, "peter":45} print(list(d.keys()))

Question 35 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? test = {1:'A', 2:'B', 3:'C'} test = {} print(len(test))

Question 36 of 40
★ FPSC ★ PPSC

Which of the following statements create a dictionary?

Question 37 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? a={1:"A",2:"B",3:"C"} for i,j in a.items(): print(i,j,end=" ")

Question 38 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code snippet? test = {1:'A', 2:'B', 3:'C'} del test[1] test[1] = 'D' del test[2] print(len(test))

Question 39 of 40
★ FPSC ★ PPSC

What will be the output of the following Python code? >>> a={1:"A",2:"B",3:"C"} >>> a.items()

Question 40 of 40
★ FPSC ★ PPSC

Which of the statements about dictionary values if false?

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 Examiner's Advisory for Programming & Software Development

In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →