Jump to content

Averages/Arithmetic mean: Difference between revisions

m (→‎{{header|Perl}}: Added an optional semicolon)
Line 300:
 
=={{header|Python}}==
avg = lambda x: sum(x or [0])/float(len(x or [0]))
print avg([3,1,4,1,5,9])
 
Output:
3.83333333333333
 
def avg(data):
return sum(data)/float(len(data)) if len(data)!=0 else 0
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.