Complete the code to define a local variable x inside the function.
def my_function(): [1] = 10 print(x)
The variable x is defined locally inside the function. This means it only exists inside my_function.
Complete the code to return the local variable result from the function.
def calculate(): result = 5 + 3 return [1]
The function returns the local variable result which holds the sum.
Fix the error by completing the code to access the local variable count inside the function.
def counter(): count = 0 count += 1 print([1])
The variable count is local and must be used inside the function to print its value.
Fill both blanks to create a dictionary with keys as words and values as their lengths, only for words longer than 3 letters.
words = ['apple', 'cat', 'banana', 'dog'] lengths = {word: [1] for word in words if len(word) [2] 3}
The dictionary comprehension uses len(word) for values and filters words with length greater than 3.
Fill all three blanks to create a dictionary with uppercase keys and values only if the value is greater than 0.
data = {'a': 1, 'b': 0, 'c': 3}
result = { [1]: [2] for k, v in data.items() if v [3] 0 }The dictionary comprehension uses uppercase keys, original values, and filters values greater than zero.