Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. def average(numbers):
  2. total = float(sum(numbers))
  3. return total
  4. average = total / len(numbers)
  5. return average
  6.  
  7. Define a function called average that has one argument, numbers.
  8. Inside that function, call the built-in sum() function with the numbers list as a parameter. Store the result in a variable called total.
  9. Like the example above, use float() to convert total and store the result in total.
  10. Divide total by the length of the numbers list. Use the built-in len() function to calculate that.
  11. Return that result.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement