BugLab014 / 020up to 100
operatorsprecedencematheasy

Wrong by Design

The function average(a, b, c) should return the arithmetic mean of three numbers: add them all up and divide by three.

The formula is written right there on one line. But for most inputs, the result is way off — usually too high.

Can you spot where the math breaks down?

hint 2after hint 1
hint 3after hint 2
solution

Read the code. Before running anything: what does the last line below give?

def average(a, b, c):
"""
Returns the arithmetic mean of three numbers.
Example: average(1, 2, 3) -> 2.0
"""
return a + b + c / 3
>>> average(1, 2, 3)