Write a Python function that returns the average of a list of values, and then test...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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). 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).
Expert Answer:
Answer rating: 100% (QA)
Python import random def avglistnumbers low0 high100 Calculate the average of values in ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Show how the circuit derived in Problem 6.15 can be modified such that the code y 4 y 3 y 2 y 1 = 0000 is used for the reset state, A, and the other codes for stateB, C,Dare changed as needed. Data...
-
The risk free rate is currently 2% and the required return on the market portfolio is 8%.If a specific stock is estimated to have a CAPM beta coefficient of 1.2 and the $2.00 per share dividend paid...
-
Businesses use budgets to plan for the future. Thats what you will be doing for this assignment. Rather than budgeting for your current financial situation, I want you to put together a budget for...
-
A Contractors Ltd was formed on 1 January 2012 and the following purchases and sales of machinery were made during the first 3 years of operations. Each machine was estimated to last 10 years and to...
-
Find the inverse Laplace transform of the following function F(s) = (s + 1) e-s / s(s + 2) F(s) = 10e-2s / (s + 1) (s + 3)
-
On April 30, 2017, Oceanarium Corporation ordered a new passenger ship, which was delivered to the designated cruise port and available for use as of June 30, 2017. Overall, the cost of the ship was...
-
Methane is compressed adiabatically from \(100 \mathrm{kPa}(\mathrm{abs})\) and \(25^{\circ} \mathrm{C}\) to \(200 \mathrm{kPa}(\) abs). What is the minimum compressor exit temperature possible?...
-
In Problem, suppose that the objective is to minimize the cost of books and that the student total study time is limited to 12,600 hours. A business student at Nowledge College must complete a total...
-
An iron boiler of mass 188 kg contains 690 kg of water at 19C. A heater supplies energy at the rate of 58,000 kJh.How long does it take for the water (a) to reach the boiling point, and (b) to all...
-
The Harvey City Comprehensive Case consists of the last problem in each chapter from Chapters 4 through 15. Completing this case essentially requires that you account for all the transactions of a...
-
ABC Corp. is an all-equity firm and has 50 million outstanding shares. The firm has a net income of $200 million per year, which is expected to continue at this level forever. The required risk...
-
Do patients at HCCI have the same expectations as far as care and personal touch go as their patients in India? What does it mean from a task-shifting standpoint?
-
Give the machine code for the following instruction: ADD X0, X0, #0x64 Write your answer in hex with a leading Ox.
-
A company allocates overhead using a standard overhead rate of $4.80 per direct labor hour and 2 direct labor hours per unit. For this period, the company planned production of 10,140 units (80% of...
-
Resolve this java code class Coin { private final int HEADS = 0; private final int TAILS = 1; private int face; // Sets up the coin by flipping it initially. public Coin() { flip(); } // Flips the...
-
use the data from your table greatest to least number of particles. Justify your answers. to rank the samples from Carbon 240 Oxygen 18 Rank the substances in terms of their numbers of particles:...
-
The vapour pressure of an aqueous solution is found to be 750 torr at certain temperature 'T'. If 'T' is the temperature at which pure water boils under atmospheric pressure and same solution show...
-
A line l passes through the points with coordinates (0, 5) and (6, 7). a. Find the gradient of the line. b. Find an equation of the line in the form ax + by + c = 0.
-
Frank, age 35, and Joyce, age 34, are married and file a joint income tax return for 2012. Their salaries for the year total $83,000 and they have taxable interest income of $4,000. They have no...
-
Jerry made the following contributions during 2012: His synagogue (by check).....................................................$680 The Democratic Party (by check)...
-
On February 2, 2012, Alexandra purchases a personal computer for her home. The computer cost $3,000. Alexandra uses the computer 80 percent of the time in her accounting business, 10 percent of the...
-
Which forecasting technique is more qualitative, the Delphi method or linear regression?
-
A road-paving crew required 8 hours to repave a 3-mile stretch of road, using \($5,000\) in materials. The crew consisted of three workers who each earn \($25\) an hour. Calculate a multifactor...
-
An automobile assembly plant produced 600 cars during a 5-day workweek. It then produced 500 cars the following week, although it only operated 4 days due to a national holiday. During which week was...
Study smarter with the SolutionInn App