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. In Python 3.7 and later, what is the behavior regarding dictionary key order?

 
 
 
 

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

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

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

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

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

 
 
 
 

5. Please the correct way to empty following dictionary

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

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

 
 
 
 

7. Select correct ways to create an empty dictionary

 
 
 
 

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

 
 
 
 

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

 
 
 
 

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

 
 
 
 

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

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

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

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

 
 
 
 

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

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

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

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

16. Dictionary keys must be immutable

 
 

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

 
 
 
 

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

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

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

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

20. What will be the output of the following dictionary operation?

dict1 = {"name": "Mike", "salary": 8000}
temp = dict1.pop("age")
print(temp)
 
 

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

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

 
 
 
 

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

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

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

 
 
 
 

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

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

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

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