This project has a Python file with a few small functions you need to complete. Each function has a TODO comment telling you what it should do — like counting items, adding numbers, or finding vowels in a string.
Once you finish the functions, you can run tests to check your work.
- Make sure you have Python 3 installed.
- Save your file as
test_loops.pyin your project folder. - Open your terminal or command prompt.
- Run this command to test it:
python -m unittest test_loops.py| Function | What it should return |
|---|---|
count_items(items) |
The number of items in a list |
sum_numbers(numbers) |
The sum of all numbers |
find_largest(numbers) |
The largest number in the list |
count_even_numbers(numbers) |
How many even numbers are in the list |
sum_digits(number) |
The sum of all digits in a number |
count_vowels(string) |
The number of vowels (a, e, i, o, u) in a string |
multiply_list_elements(numbers) |
The product of all numbers in the list |
python test_loops.pyExample output:
All tests passed!
or
Test failed: find_largest()
Keep fixing the functions until all tests pass.