Sobes.tech
Intern — Senior

Develop a unit test for a function that returns even numbers

livecode

Task condition

There is a function get_even_numbers(n: int = 10) -> list that generates a list of all even numbers in the range from 0 to n-1. It is necessary to write a test that checks the correctness of its operation for various input parameters.

def get_even_numbers(n: int = 10) -> list:
    evens = []
    for num in range(n):
        if not num % 2:
            evens.append(num)
    return evens

The test should compare the result of the function with the expected array of even numbers, including boundary cases (n = 0, n = 1, typical values).

Develop a unit test for a function that returns even… - sobes.tech