Kodewick
Start learning →
Basic←→0 / 100

Class average

#044BasicListsNumbers4 min

The teacher keeps the class's scores in a list. Write average(scores) to return the average, rounded to one decimal place with round. If the list is empty (nobody has handed in yet), return 0.

Examples
average([90, 80, 70])→80.0
average([88, 92])→90.0
average([])→0
main.py
def average(scores):
    if len(scores) == 0:
        return 0
    # your code here: the total over how many, to 1 decimal place

Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.