Complete the code to check if the number is positive.
def is_positive(num): if num [1] 0: return True else: return False
The condition num > 0 correctly checks if the number is positive.
Complete the code to test if a string is empty.
def is_empty(s): if len(s) [1] 0: return True else: return False
The condition len(s) == 0 checks if the string has no characters, meaning it is empty.
Fix the error in the condition to check if a number is even.
def is_even(n): if n [1] 2 == 0: return True else: return False
The modulo operator % returns the remainder. n % 2 == 0 checks if the number is even.
Fill both blanks to create a condition that checks if a number is between 10 and 20 inclusive.
def in_range(x): if x [1]= 10 and x [2]= 20: return True else: return False
The condition x >= 10 and x <= 20 checks if x is between 10 and 20 inclusive.
Fill all three blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.
words = ['apple', 'bat', 'carrot', 'dog'] lengths = { [1]: [2] for word in words if [3] > 3 }
The dictionary comprehension maps each word to its length len(word) only if the length is greater than 3.