Loading...
Quiz: Python Dictionary
Practice Python dictionaries with this quiz. Covering key concepts like dictionary creation, access, update, deletion, and nesting.
1.
What is the correct way to define a dictionary in Python?
2.
What will be the output of the following code?
python
2 lines
|15/ 500 tokens
1 2car = {"brand": "Toyota", "year": 2022} print(car["brand"])
Code Tools
3.
What happens if a dictionary is defined with duplicate keys?
4.
What does the following code print?
python
3 lines
|19/ 500 tokens
1 2 3car = {"brand": "Tesla", "year": 2020} car["year"] = 2021 print(car["year"])
Code Tools
5.
What will this return?
python
2 lines
|13/ 500 tokens
1 2car = {"brand": "BMW", "year": 2019} print(len(car))
Code Tools
6.
How do you access a nested dictionary item?
python
1 lines
|10/ 500 tokens
1family = {"child": {"name": "Alice"}}
Code Tools