Python BasicsIntro
Numbers and Arithmetic
~7 mincode completion
Write that returns the mean of three numbers.
The mean is the total divided by how many there are, so for 3, 4, 5 it is (3 + 4 + 5) / 3, which is 4.0.
Examples
- Input
- average(3, 4, 5)
- Output
- 4
The result is a float even when it comes out even
- Input
- average(2, 4, 6)
- Output
- 4
Works when the answer is not a whole number
- Input
- average(1, 2, 2)
- Output
- 1.66667
Hints
Hint 1
Work directly with the arguments a, b, c and return the result rather than printing it.
Hint 2
Do not forget to parentheses around sum. That step is easy to skip.
Requirements
Return Their mean, as a float.
Constraints
Standard library only, no imports required
Time limit: 200 ms, Memory: 64 MB
Where this shows up
~7 min
••••••
3 employers weight this skill
2 frontier labs, 1 AI product company. Top match scores 80.
Python
def average(a, b, c):
"""
Return the mean of three numbers.
Args:
a, b, c: numbers (ints or floats)
Returns:
Their mean, as a float.
"""
# YOUR CODE HERE
pass