Introduction
In Python, calculating the average of a set of numbers is a common task. In this challenge, you will be asked to write a function that takes in two or more numbers and returns their average.
This tutorial is from open-source community. Access the source code
In Python, calculating the average of a set of numbers is a common task. In this challenge, you will be asked to write a function that takes in two or more numbers and returns their average.
Write a function called average
that takes in two or more numbers and returns their average. Your function should follow these guidelines:
sum()
to sum all of the args
provided, divide by len()
.average(*[1, 2, 3]) ## 2.0
average(1, 2, 3) ## 2.0
In this challenge, you have written a function that calculates the average of two or more numbers. You have used the sum()
function to add up all of the numbers and then divided by the number of arguments using len()
. This is a useful function to have in your Python toolbox for future projects.