Practice and master Python dictionaries with interactive fill-in-the-blanks exercises. Strengthen your understanding of key-value pairs, dictionary methods, and data manipulation. Ideal for beginners and students learning Python.
Topic: dictionaries
key-value
Dictionaries store data as key-value pairs where each key maps to a value.
{}
You can create an empty dictionary using curly braces {} or the dict() constructor.
key
Values are accessed by using their keys inside square brackets: dict[key].
square
Use square brackets to assign a value to a new or existing key: dict[key] = value.
keys()
The keys() method returns a view object of all keys in the dictionary.
values()
The values() method returns a view object of all values in the dictionary.
pop()
The pop() method removes the specified key and returns its value.
items()
The items() method returns a view object with the dictionary’s key-value pairs.
in
Use 'in' to check if a key exists: 'key' in dict.
unordered and unique-keyed
Python dictionaries are unordered collections and do not allow duplicate keys.
Tutorials, Roadmaps, Bootcamps & Visualization Projects