Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 1

Python import random def avglistnumbers low0 high100 Calculate the average of values in ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions