Complete the code to access the value of the key 'name' in the dictionary.
person = {'name': 'Alice', 'age': 30}
print(person[1])The key 'name' is used inside square brackets to get its value from the dictionary.
Complete the code to print the value of the key 'color' from the dictionary.
car = {'brand': 'Toyota', 'color': 'red', 'year': 2020}
print(car[1])To get the color of the car, use the key 'color' inside square brackets.
Fix the error in the code to correctly access the value of the key 'score'.
results = {'score': 85, 'grade': 'B'}
print(results[1])Dictionary keys must be accessed using square brackets and the key as a string.
Fill both blanks to create a dictionary comprehension that maps each word to its length.
words = ['apple', 'banana', 'cherry'] lengths = {word[1] for word in words if len(word) [2] 5}
The dictionary comprehension maps each word to its length using ':' and filters words longer than 5 using '>'.
Fill all three blanks to create a dictionary of uppercase keys and their values, filtering values greater than 10.
data = {'a': 5, 'b': 15, 'c': 20}
result = [1]: [2] for k, v in data.items() if v [3] 10}The comprehension uses k.upper() as keys, v as values, and filters values greater than 10 with '>'.