Question: Write a Python function that returns the average of a list of values, and then test it with a variety of inputs. Restriction: I
Write a Python function that returns the average of a list of values, and then test it with a variety of inputs. Restriction: I want you to write the average function yourself (from scratch), you cannot use np. mean (), mean (), or any other average function. Hint: Remember the mean of a function is just the sum of all the values, divided by the number of values in the list. Requirements: Create function with name avglist that accepts three parameters: . 1st - list of numbers (required parameter) low - miminum value (not inclusive). (optional parameter, default = 0) high - maximum value (not inclusive). (optional parameter default = 100) Your function will calculate and return the average of all values in the range (low, high). . Your function should have an appropriate docstring. Call help (avglist) to display function information. Create a list with the numbers 1 to 10 and call avglist () with default range and print the result. Create a list with the numbers 1 to 100 and call avglist () with range (20, 80) and print result. Create a list with 100 random numbers between 1 and 100 and call avglist() with range (30, 100) and print the result. Note: Will need to import random and use random. randint (1, 100). Reminder: To set the seed, use random. seed (100).
Step by Step Solution
There are 3 Steps involved in it
Python import random def avglistnumbers low0 high100 Calculate the average of values in ... View full answer
Get step-by-step solutions from verified subject matter experts
