Complete the code to arrange the test data correctly.
def test_sum(): numbers = [1] result = sum(numbers) assert result == 6
The test data should be a list to use with sum(). So [1, 2, 3] is correct.
Complete the code to act by calling the function under test.
def test_uppercase(): text = "hello" result = text.[1]() assert result == "HELLO"
lower() which converts to lowercase.capitalize() which only changes the first letter.The upper() method converts text to uppercase, matching the assertion.
Fix the error in the assertion to correctly check the result.
def test_length(): word = "test" length = len(word) assert length [1] 5
== 5 which fails because length is 4.> 5 which is false.The length of "test" is 4, which is less than 5, so < is correct.
Fill both blanks to create a test that asserts a list contains a value.
def test_contains(): items = [1, 2, 3] value = 2 assert value [1] items[2]
== which compares value to the whole list.not in which would fail the test.The correct syntax to check if a value is in a list is value in items. The second blank is empty because no extra operator is needed.
Fill all three blanks to create a dictionary comprehension that filters items by value.
def test_filter_dict(): data = {'a': 1, 'b': 3, 'c': 2} filtered = {k: v for k, v in data.items() if v [1] [2] assert filtered == [3]
< instead of > which changes the filter.The comprehension filters values greater than 1, so v > 1. The expected filtered dictionary is {'b': 3, 'c': 2}.