Complete the code to print a message only if the number is positive.
number = 5 if number [1] 0: print("Number is positive")
The condition number > 0 checks if the number is positive.
Complete the code to print 'Even' if the number is divisible by 2.
number = 8 if number [1] 2 == 0: print("Even")
The modulus operator % gives the remainder. If remainder is 0, number is divisible by 2.
Fix the error in the code to check if a number is not zero.
number = 0 if number [1] 0: print("Number is not zero")
The operator != means 'not equal to', so it checks if number is not zero.
Fill both blanks to create a dictionary of squares for numbers greater than 3.
squares = {x: x[1]2 for x in range(1, 6) if x [2] 3}Use ** to square the number and > to check if number is greater than 3.
Fill all three blanks to create a dictionary of uppercase keys and values greater than zero.
result = [1]: [2] for k, v in data.items() if v [3] 0}
Use k.upper() to make keys uppercase, v as values, and > to filter values greater than zero.
