Complete the code to print 'Yes' if the number is greater than 10.
number = 15 if number [1] 10: print("Yes")
The condition should check if number is greater than 10, so we use the > operator.
Complete the code to print 'Even' if the number is divisible by 2.
number = 8 if number [1] 2 == 0: print("Even")
The modulo operator % gives the remainder. If number % 2 == 0, the number is even.
Fix the error in the if statement to correctly check if x is not equal to 5.
x = 7 if x [1] 5: print("Not five")
The operator != means 'not equal to'. Using = is assignment, which causes an error here.
Fill both blanks to create a dictionary of words and their lengths, but only for words longer than 3 letters.
words = ["apple", "cat", "banana", "dog"] lengths = {word: [1] for word in words if len(word) [2] 3}
We want the length of each word as the value, so use len(word). The condition should check if length is greater than 3, so use >.
Fill all three blanks to create a dictionary with uppercase keys and values only if the value is positive.
data = {"a": 1, "b": -2, "c": 3}
result = [1]: [2] for k, v in data.items() if v [3] 0}Keys should be uppercase, so use k.upper(). Values are v. The condition checks if v is greater than 0, so use >.