Complete the code to get all keys from the dictionary.
my_dict = {'a': 1, 'b': 2, 'c': 3}
keys = my_dict.[1]()
print(keys)The keys() method returns all the keys in a dictionary.
Complete the code to get all values from the dictionary.
my_dict = {'x': 10, 'y': 20, 'z': 30}
vals = my_dict.[1]()
print(vals)The values() method returns all the values in a dictionary.
Fix the error in the code to get all key-value pairs from the dictionary.
data = {'name': 'Alice', 'age': 25}
pairs = data.[1]()
print(pairs)The items() method returns all key-value pairs as tuples.
Fill both blanks to create a dictionary of word lengths for words longer than 3 letters.
words = ['apple', 'bat', 'carrot', 'dog'] lengths = {word: [1](word) for word in words if len(word) [2] 3} print(lengths)
Use len(word) to get the length of each word and filter words with length greater than 3 using >.
Fill all three blanks to create a dictionary with uppercase keys and values greater than 10.
data = {'a': 5, 'b': 15, 'c': 25}
filtered = [1]: [2] for [3], val in data.items() if val > 10}
print(filtered)Use k.upper() to make keys uppercase, val for values, and k as the key variable in the loop.
