Question & Answer: Create a function that will take a list of floats as an argument. The function will then f…..

Create a function that will take a list of floats as an argument. The function will then find the average of that list and return it as a float. Test your function by calling it and printing the average.

Python Code 3.
Need help

Expert Answer

# python program to caculate the average of numbers in the given list

# average function definition
def average(list):
avg=0

#both sum() and len() are pre-defined functions in python

# sum() function is used to calculate the total of numbers in the given list
# len() function is used to calcualte the count of numbers in the given list

avg=sum(list)/len(list)
return avg

print ‘Enter the list of numbers’;
# input() function is used to read the list of values

# reading list of values into y

y=input()

# passing list of y values to the function average
result=average(y)
print ‘average of gvien list of numbers is’,result

OUTPUT:

Question & Answer: Create a function that will take a list of floats as an argument. The function will then f..... 1

Still stressed from student homework?
Get quality assistance from academic writers!