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. Select the correct ways to get the value of marks key.

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

2. 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"])
 
 
 
 

3. In Python, Dictionaries are immutable

 
 

4. Dictionary keys must be immutable

 
 

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

 
 
 
 

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

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

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

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

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

 
 
 
 

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

10. Please the correct way to empty following dictionary

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

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

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

 
 
 
 

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

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

14. Select correct ways to create an empty dictionary

 
 
 
 

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 happens if you try to add a new key-value pair to a dictionary where the key already exists?

 
 
 
 

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

 
 
 
 

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

 
 
 
 

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

my_dict = {"a": 1, "b": 2}
my_dict["c"] = 3
print(my_dict["a"])
 
 
 
 

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

 
 
 
 

21. Which of the following iterables can be directly converted to a dictionary using the dict() constructor?

 
 
 
 

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

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

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

 
 
 
 

24. 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?

 
 
 
 

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

 
 
 
 

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