0
0
Pythonprogramming~10 mins

Nested dictionaries in Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a nested dictionary with a key 'person' and a nested key 'name'.

Python
data = {'person': {'name': [1]
Drag options to blanks, or click blank then click option'
Aname
BAlice
C'Alice'
D"name"
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Forgetting quotes around string values.
Using variable names without defining them.
2fill in blank
medium

Complete the code to access the nested value 'city' inside the 'address' dictionary.

Python
city = info['address'][[1]]
Drag options to blanks, or click blank then click option'
Acity
B'city'
C"address"
D'address'
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using the key without quotes.
Using the wrong key name.
3fill in blank
hard

Fix the error in the code to correctly add a nested dictionary under the key 'contact'.

Python
data['contact'] = [1]
Drag options to blanks, or click blank then click option'
A{'phone': '123-4567'}
B{phone: '123-4567'}
C['phone', '123-4567']
D('phone', '123-4567')
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using unquoted keys causing syntax errors.
Using list or tuple instead of dictionary.
4fill in blank
hard

Fill both blanks to create a nested dictionary with keys 'student' and 'grade'.

Python
record = { [1]: [2] }
Drag options to blanks, or click blank then click option'
A'student'
B'grade'
C90
D{'grade': 90}
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Not quoting the key 'student'.
Using a number instead of a dictionary for the value.
5fill in blank
hard

Fill both blanks to create a nested dictionary with keys 'team', 'player', and 'score'.

Python
game = { [1]: [2] }
Drag options to blanks, or click blank then click option'
A'team'
B{'player': 'John', 'score': 10}
C'player'
D'score'
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Not quoting keys.
Using incorrect data types for nested values.