Complete the code to assert that the sum of 2 and 3 equals 5.
def test_sum(): result = 2 + 3 assert result [1] 5
The assert statement checks if the expression is true. Here, result == 5 verifies the sum is correct.
Complete the code to assert that the length of the list is 4.
def test_list_length(): items = [1, 2, 3, 4] assert len(items) [1] 4
The assert checks if the length of items is exactly 4 using ==.
Fix the error in the assert statement to correctly check if the variable is True.
def test_is_active(): is_active = True assert is_active [1] True
The correct way to compare values in an assert is with ==. Using = causes a syntax error.
Fill both blanks to assert that the variable score is greater than 50.
def test_score(): score = 75 assert score [1] [2]
The assert checks if score is greater than 50 using > and the number 50.
Fill all three blanks to assert that the length of names is less than 5 and the first name is 'Alice'.
def test_names(): names = ['Alice', 'Bob', 'Charlie'] assert len(names) [1] [2] and names[0] [3] 'Alice'
The assert checks two things: length of names is less than 5 (< and 5), and the first name equals 'Alice' (==).