Command Palette

Search for a command to run...

Hectal
Phase 5: Functions
Python · Exercise 3 of 6 PreviousNext
Beginner

Average of any number of values

Write average(*numbers) that returns the mean of all the arguments (their sum divided by how many there are). With no arguments it returns 0.

Replace the return None line with your code. The last line of the starter already prints average(2, 4, 9), which should show 5.0.

What Check tests

  1. average(2, 4, 9) is 5.0
  2. average() is 0
  3. average(7) is 7
  4. Spreading a list works
  5. Floats and negatives work

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

main.py
Sign in to run your code.

Output

Press Run to see what your program prints.