Complete the code to check if a number is positive.
if number [1] 0: print("Positive number")
The condition number > 0 checks if the number is greater than zero, meaning it is positive.
Complete the code to print "Even" if the number is divisible by 2.
if number [1] 2 == 0: print("Even")
The modulus operator % gives the remainder of division. If number % 2 == 0, the number is even.
Fix the error in the code to check if a number is negative.
if number [1] 0: print("Negative number")
The condition number < 0 correctly checks if the number is less than zero, meaning it is negative.
Fill in the blank to print "Adult" if age is 18 or older.
if age [1] 18: print("Adult")
The condition age >= 18 checks if the age is 18 or older.
Fill all three blanks to create a dictionary of words and their lengths for words longer than 3 characters.
lengths = [1]: [2] for [3] in words if len([3]) > 3
This dictionary comprehension uses word as the variable to iterate over words. The key is word itself, and the value is len(word), but only for words longer than 3 characters.