Complete the code to return two values from the function.
def get_coordinates(): x = 10 y = 20 return [1]
The function returns two values separated by a comma, which Python treats as a tuple.
Complete the code to unpack the returned values into variables.
def get_name_and_age(): return "Alice", 30 name, [1] = get_name_and_age()
The function returns two values, so we unpack them into two variables: name and age.
Fix the error in the function to correctly return multiple values.
def calculate(): sum = 5 + 3 diff = 5 - 3 return [1]
Returning sum, diff returns both values as a tuple, which is the correct way to return multiple values.
Fill both blanks to create a function that returns the square and cube of a number.
def powers(num): square = num [1] 2 cube = num [2] 3 return square, cube
The exponent operator '**' is used to calculate powers in Python.
Fill all three blanks to create a dictionary comprehension that maps words to their length if length is greater than 3.
words = ["apple", "bat", "car", "door"] lengths = { [1]: [2] for [3] in words if len([3]) > 3 }
The dictionary comprehension uses the word as the key and its length as the value, filtering words longer than 3 characters.