Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def average(numbers):
- total = float(sum(numbers))
- return total
- average = total / len(numbers)
- return average
- Define a function called average that has one argument, numbers.
- Inside that function, call the built-in sum() function with the numbers list as a parameter. Store the result in a variable called total.
- Like the example above, use float() to convert total and store the result in total.
- Divide total by the length of the numbers list. Use the built-in len() function to calculate that.
- Return that result.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement