Complete the code to create a dictionary with a key 'name' and value 'Alice'.
person = [1]The correct way to create a dictionary is using curly braces with key-value pairs inside, like {'name': 'Alice'}.
Complete the code to access the value of the key 'age' from the dictionary.
age = person[1]To get a value from a dictionary, use square brackets with the key as a string, like person['age'].
Fix the error in the code to add a new key 'city' with value 'Paris' to the dictionary.
person[1] = 'Paris'
To add or update a key-value pair in a dictionary, use square brackets with the key as a string, like person['city'] = 'Paris'.
Complete the code to create a dictionary comprehension that maps each word to its length for words longer than 3 letters.
{word: len(word) for word in words if len(word) [1] 3}In dictionary comprehensions, use a colon ':' to separate keys and values. The condition checks if the word length is greater than 3 using '>'.
Fill all three blanks to create a dictionary from a list of tuples, where keys are names in uppercase and values are ages greater than 20.
result = [1]: [2] for name, age in data if age [3] 20}
name.lower() instead of uppercase changes keys incorrectly.= instead of > causes syntax errors.The key is the uppercase name using name.upper(), the value is age, and the condition filters ages greater than 20 using >.