PYnative

Python Programming

  • Learn Python
    • Python Tutorials
    • Python Basics
    • Python Interview Q&As
  • Exercises
    • Python Exercises
    • C Programming Exercises
    • C++ Exercises
  • Quizzes
  • Code Editor
    • Online Python Code Editor
    • Online C Compiler
    • Online C++ Compiler
Home » Python » Quizzes » Python Dictionary Quiz

Python Dictionary Quiz

Updated on: August 26, 2025 | 14 Comments

This Python dictionary quiz provides Multiple Choice Questions(MCQs) to test and solidify your understanding of how dictionaries work in Python.

The quiz covers questions on the below topics.

  • Dictionary Creation: Various ways to define and initialize dictionaries.
  • Accessing Elements: Retrieving values using their corresponding keys.
  • Modifying Dictionaries: Adding, updating, and deleting key-value pairs.
  • Dictionary Methods: Utilizing built-in functions like keys(), values(), items(), get(), pop(), update(), and clear().
  • Dictionary Properties: Understanding concepts like mutability and the immutability of keys.
  • Nested Dictionaries: Working with dictionaries within dictionaries.

Also, See:

  • Python Dictionary Exercise.
  • 15 Python Quizzes: each focusing on a specific topic
  • The quiz contains 25 questions. There is no time limit.
  • Explanation is provided for each answer.
  • You will get 1 point for each correct answer. Solve 15 correctly to pass the test
  • Read guide on Dictionaries in Python to solve this quiz

1. What will be the output of the following Python code?

my_dict = {"x": 10}
print(my_dict.get("y", "Key Not Found"))
print(my_dict.get("x", "Key Not Found"))
 
 
 
 

2. Which method is used to remove all key-value pairs from a dictionary, making it empty?

 
 
 
 

3. What will be the output of the following Python code?

profile = {"name": "John", "age": 25, "city": "New York"}
keys = list(profile.keys())
keys.sort()
print(keys[0])
 
 
 
 

4. Dictionary keys must be immutable

 
 

5. Which method removes a specified key and its associated value from a dictionary, returning the value, and raising a KeyError if the key is not found?

 
 
 
 

6. Which operator or method is typically used to merge two dictionaries in Python (from Python 3.9 onwards)?

 
 
 
 

7. Please the correct way to empty following dictionary

student = { 
  "name": "Emma", 
  "class": 9, 
  "marks": 75 
}
 
 
 

8. Why must dictionary keys be immutable (hashable)?

 
 
 
 

9. Select the correct way to print Emma’s age.

student = {1: {'name': 'Emma', 'age': '27', 'sex': 'Female'},
           2: {'name': 'Mike', 'age': '22', 'sex': 'Male'}}
 
 
 
 

10. Which of the following is NOT a valid way to create a Python dictionary?

 
 
 
 

11. What does dict.fromkeys(['a', 'b'], 0) return?

 
 
 
 

12. When you use dict1.copy() to create dict2 = dict1.copy(), what kind of copy is created?

 
 
 
 

13. What will be the output of the following Python code?

my_dict = {"a": 1, "b": 2}
value = my_dict.pop("b")
print(value)
print(my_dict)
 
 
 
 

14. What will be the output of the following Python code?

d1 = {"a": 1, "b": 2}
d2 = {"b": 3, "c": 4}
d1.update(d2)
print(d1["b"])
 
 
 
 

15. What will be the output of the following Python code?

dict1 = {"key1":1, "key2":2}
dict2 = {"key2":2, "key1":1}
print(dict1 == dict2)
 
 

16. What will be the output of the following Python code?

config = {"theme": "dark", "font_size": 12}
config.setdefault("language", "en")
config.setdefault("theme", "light") # Already exists
print(config)
 
 
 
 

17. In Python, Dictionaries are immutable

 
 

18. What happens if you try to add a new key-value pair to a dictionary where the key already exists?

 
 
 
 

19. What will be the output of the following Python code?

mapping = dict(zip(['one', 'two'], [1, 2]))
print(mapping)
 
 
 
 

20. Which of the following best describes a Python dictionary?

 
 
 
 

21. What will be the output of the following Python code?

sampleDict = dict([
    ('first', 1),
    ('second', 2),
    ('third', 3)
])
print(sampleDict)
 
 
 

22. Select all correct way to remove the key marks from a dictionary

student = { 
  "name": "Emma", 
  "class": 9, 
  "marks": 75 
}
 
 
 
 

23. What do dict.keys(), dict.values(), and dict.items() return in Python 3?

 
 
 
 

24. What will be the output of the following Python code?

data = {"name": "Alice", "age": 30}
print("name" in data)
print("city" in data)
 
 
 
 

25. What will be the output of the following Python code?

data = {"x": 10, "y": 20}
data["z"] = data.pop("x")
print(data)
 
 
 
 

Loading ... Loading …

Loading

Filed Under: Python, Python Basics, Python Quizzes

Did you find this page helpful? Let others know about it. Sharing helps me continue to create free Python resources.

TweetF  sharein  shareP  Pin

About Vishal

Image

I’m Vishal Hule, the Founder of PYnative.com. As a Python developer, I enjoy assisting students, developers, and learners. Follow me on Twitter.

Related Tutorial Topics:

Python Python Basics Python Quizzes

All Coding Exercises:

C Exercises
C++ Exercises
Python Exercises

Python Exercises and Quizzes

Free coding exercises and quizzes cover Python basics, data structure, data analytics, and more.

  • 15+ Topic-specific Exercises and Quizzes
  • Each Exercise contains 25+ questions
  • Each Quiz contains 25 MCQ
Exercises
Quizzes

Loading comments... Please wait.

In: Python Python Basics Python Quizzes
TweetF  sharein  shareP  Pin

  Python Quizzes

  • 15 Python Quizzes
  • Python Online MCQ Test
  • Basic Quiz For Beginners
  • Variables and Data Types Quiz
  • Functions Quiz
  • if else and loops Quiz
  • Numbers Quiz
  • String Quiz
  • List Quiz
  • Set Quiz
  • Dictionary Quiz
  • Tuple Quiz
  • Operators and Expression Quiz
  • Input and Output Quiz
  • Multithreading and Multiprocessing Quiz
  • File Handling Quiz
  • Random Data Generation Quiz

 Explore Python

  • Python Tutorials
  • Python Exercises
  • Python Quizzes
  • Python Interview Q&A
  • Python Programs

All Python Topics

Python Basics Python Exercises Python Quizzes Python Interview Python File Handling Python OOP Python Date and Time Python Random Python Regex Python Pandas Python Databases Python MySQL Python PostgreSQL Python SQLite Python JSON

About PYnative

PYnative.com is for Python lovers. Here, You can get Tutorials, Exercises, and Quizzes to practice and improve your Python skills.

Follow Us

To get New Python Tutorials, Exercises, and Quizzes

  • Twitter
  • Facebook
  • Sitemap

Explore Python

  • Learn Python
  • Python Basics
  • Python Databases
  • Python Exercises
  • Python Quizzes
  • Online Python Code Editor
  • Python Tricks

Coding Exercises

  • C Exercises
  • C++ Exercises
  • Python Exercises

Legal Stuff

  • About Us
  • Contact Us

We use cookies to improve your experience. While using PYnative, you agree to have read and accepted our:

  • Terms Of Use
  • Privacy Policy
  • Cookie Policy

Copyright © 2018–2026 pynative.com

Advertisement