PYnative

Python Programming

  • Learn Python ▼
    • Python Tutorials
    • Python Basics
    • Python Interview Q&As
  • Exercises ▼
    • Python Exercises
    • C++ Exercises
    • C Programming Exercises
    • Java Exercises
    • C# Exercises
  • Quizzes ▼
    • Python Quizzes
    • Java MCQ Quizzes
  • Online Compilers▼
    • Online Python Code Editor
    • Online C Compiler
    • Online C++ Compiler
    • Online Java 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 does the dict.popitem() method do?

 
 
 
 

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

 
 
 
 

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

 
 
 
 

4. Select the correct ways to get the value of marks key.

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

5. Dictionary keys must be immutable

 
 

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

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

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

 
 
 
 

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

 
 

9. Select the correct way to access the value of a history subject

sampleDict = { 
   "class":{ 
      "student":{ 
         "name":"Mike",
         "marks":{ 
            "physics":70,
            "history":80
         }
      }
   }
}
 
 
 
 

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

 
 
 
 

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

 
 
 
 

14. In Python, Dictionaries are immutable

 
 

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

 
 
 
 

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

 
 
 
 

17. Select correct ways to create an empty dictionary

 
 
 
 

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

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

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

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

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

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

 
 
 
 
 

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

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

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

 
 
 
 

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
Java Exercises
C# 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
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
  • Java Exercises
  • C# 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
Advertisement