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?

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

2. In Python, Dictionaries are immutable

 
 

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

 
 
 
 

4. What does the dict.popitem() method do?

 
 
 
 

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

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

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

7. Select correct ways to create an empty dictionary

 
 
 
 

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

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

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

grades = {"Math": 90, "Science": 85, "English": 92}
for subject in grades:
    print(subject)
 
 
 
 

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

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

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

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

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

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

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

14. Is Below statement True?

Items are accessed by their position in a dictionary and All keys in a dictionary must be of the same type.

 
 

15. Which method is used to get the value associated with a given key, returning None or a specified default if the key is not found?

 
 
 
 

16. What is the primary use case for the dict.setdefault(key, default_value) method?

 
 
 
 

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

18. Dictionary keys must be immutable

 
 

19. In Python 3.7 and later, what is the behavior regarding dictionary key order?

 
 
 
 

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

 
 
 
 

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

 
 
 
 

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

 
 
 
 

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

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

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

 
 
 
 

25. Select all correct ways to copy a dictionary in Python

 
 
 
 
 

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