Complete the code to print the result of a simple test assertion.
assert [1] == 5
The expression 2 + 3 equals 5, so the assertion passes.
Complete the code to check if a list contains a specific element.
assert 'bug' [1] ['bug', 'test', 'fix']
The keyword in checks if an element is inside a list.
Fix the error in the test function definition.
def test_example(): result = 10 / [1] assert result == 5
Dividing 10 by 2 gives 5, so the assertion passes. Dividing by 0 causes an error.
Fill both blanks to create a dictionary comprehension filtering even numbers.
evens = {num: num[1]2 for num in range(1, 6) if num [2] 2 == 0}The expression num**2 squares the number. The condition num % 2 == 0 filters even numbers.
Fill all three blanks to create a filtered dictionary with uppercase keys and positive values.
filtered = [1]: [2] for [3] in data.items() if [2] > 0
Keys are converted to uppercase with k.upper(). Values v are used and filtered to be positive. Loop variables are k, v for key and value.