Specification The script must define 4 functions list_average list_minimum list_
ID: 3688712 • Letter: S
Question
Specification
The script must define 4 functions
list_average
list_minimum
list_maximum
above_average
This functions must have the following header
This function should compute the average of the numbers in the last and return that number rounded to the nearest whole number. This functions must have the following header
This function should loop through the list and find the smallest number in the list.
You should assume that no number in the list is greater than 100. This functions must have the following header
This function should loop through the list and find the largest number in the list.
You should assume that no number in the list is less than o. This functions must have the following header
This function should call list_avearage to compute the average and count the number of entries that are greater than that average.
Run code
At the bottom of the script you must have the following code
Testing
Your output should look exactly like this
Explanation / Answer
def list_average(number_list):
sum = 0
i = 0
for ele in number_list:
sum = sum + ele
i = i +1
avg = sum / i
return round(avg)
def list_minimum(number_list):
min = 0
i = 0
for ele in number_list:
if(i == 0):
min = ele
elif(min > ele):
min = ele
i = i +1
return min
def list_maximum(number_list):
max = 0
i = 0
for ele in number_list:
if(i == 0):
max = ele
elif(max < ele):
max = ele
i = i +1
return max
def above_average(number_list):
avg = list_average(number_list)
i = 0
for ele in number_list:
if(ele > avg):
i = i+1
return i
numbers = [62, 60, 58, 50, 85, 93, 99, 77, 72, 74, 61, 68, 73, 65, 57]
print("numbers :", numbers)
print("average :", list_average(numbers))
print("minimum :", list_minimum(numbers))
print("maximum :", list_maximum(numbers))
print("above average:", above_average(numbers))
===output===========
numbers : [62, 60, 58, 50, 85, 93, 99, 77, 72, 74, 61, 68, 73, 65, 57]
average : 70
minimum : 50
maximum : 99
above average: 7
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.