id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

average


Write a function named average that accepts a list of integers as its parameter and returns the average (arithmetic mean) of all elements in the list as a float. For example, if the list passed contains the values [1, -2, 4, -4, 9, -6, 16, -8, 25, -10], the calculated average should be 2.5. You may assume that the list contains at least one element. Your function should not modify the elements of the list.


average([12, 7, -1, 25, 5, 9]) → 9.5
average([12, 7, -1, 25, 2, 39]) → 14.0
average([1, 2, 3]) → 2.0

...Save, Compile, Run (ctrl-enter)

def average(lst):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 290 Post-solution available

Copyright Nick Parlante 2017 - privacy