Complete the code to create a dictionary with numbers as keys and their squares as values.
squares = {x: x[1]2 for x in range(1, 6)}
print(squares)The ** operator is used to raise a number to a power. Here, x**2 means x squared.
Complete the code to create a dictionary of numbers and their squares only for numbers greater than 3.
filtered_squares = {x: x**2 for x in range(1, 7) if x [1] 3}
print(filtered_squares)The condition x > 3 filters numbers greater than 3.
Fix the error in the dictionary comprehension to include only even numbers and their squares.
even_squares = {n: n**2 for n in range(1, 10) if n [1] 2 == 0}
print(even_squares)The modulo operator % gives the remainder. n % 2 == 0 checks if n is even.
Fill both blanks to create a dictionary of words and their lengths only if the length is greater than 4.
word_lengths = {word: [1] for word in words if len(word) [2] 4}The value should be the length of the word using len(word). The condition should check if length is greater than 4 using >.
Fill all three blanks to create a dictionary with uppercase words as keys and their lengths as values, only for words longer than 3 letters.
result = { [1]: [2] for word in words if len(word) [3] 3 }The key should be the uppercase word using word.upper(). The value is the length len(word). The condition filters words longer than 3 using >.