Write a complete Python program, called final.py, which will read integer values from the file numbers.txt....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a complete Python program, called final.py, which will read integer values from the file numbers.txt. The program should determine the average of the numbers in the file and then add that number to all the numbers less than the average or subtract from all the numbers greater than the average. You cannot read the file more than once so you should use the list to store the values. There should be a main function that calls a calcAvg(list) function which accepts a list of numbers and returns the average. Sample run: (numbers.txt has the following values) 1 2 2345 4 The average of the numbers is: 31 Adjusting the numbers in the list: 45312 Write a complete Python program, called final.py, which will read integer values from the file numbers.txt. The program should determine the average of the numbers in the file and then add that number to all the numbers less than the average or subtract from all the numbers greater than the average. You cannot read the file more than once so you should use the list to store the values. There should be a main function that calls a calcAvg(list) function which accepts a list of numbers and returns the average. Sample run: (numbers.txt has the following values) 1 2 2345 4 The average of the numbers is: 31 Adjusting the numbers in the list: 45312
Expert Answer:
Answer rating: 100% (QA)
Answer the code is as follow def calcAvgnumbers if not numb... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
During the accounting review, another comment caught your attention. The manager mentioned that one of the large POC consulting projects with National Bank seemed to be running well behind schedule....
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
Write a program that reads five cards from the user, then analyzes the cards and prints out the category of hand that they represent. Poker hands are categorized according to the following labels:...
-
Differentiate between formal and behavioral roles, and describe how behavioral roles emerge during group interaction.
-
Given the following functions F(s), find f(t) if F(s) = s + 1 / s(s + 2) + (s + 3) F(s) = s2 + s + 1 / s(s + 2) + (s + 1)
-
A company sold a machine that originally cost $90,000 for $28,000 cash. The accumulated depreciation on this machine was $47,000 at the time of the sale. What was the company's gain or loss on this...
-
The mean number of droughts in Asia per year from 1980 through 2008 was about 3.24. Find the probability that the number of droughts in Asia in any given year from 1980 through 2008 are (a) exactly...
-
1. Was Midlands condemnation of property in this case for a public benefit? Explain. 2. Is it fair that a city can exercise its eminent domain power to take property even though the property will not...
-
How would you respond to the following? (include questions for each response) Statement 1: Hi Destinee. Good work here, and thank you for your contributions to this thread. In hospitality,...
-
You are working on a free-form Packet Tracer challenge activity as seen in Figure 1, you have been given the London Railways network.' The purpose of this EMA question is to build upon each of the...
-
How do you record reimbursable mileage so you can add it to an invoice? Add a line to the customer invoice and choose Mileage in the Product/Service cell. Use the QuickBooks Online mileage feature to...
-
Supply Chain: Inventory Management Case Study How do we reduce inventory levels?
-
What would you do differently if you were a manager?
-
What qualities do you feel the emerging leaders from across the country should possess?
-
Here are comparative financial statement data for Sandhill Company and Wildhorse Company, two competitors. All data are as of December 31, 2022, and December 31, 2021. Net sales Cost of goods sold...
-
10-15 kg particle, has charge of 10-15 C, enter the magnetic field with speed of Vo=10m/s. Width and height of the field are given as, w=10m and h=6m. Magnetic Field alignes out of page and has 1...
-
Calculate the molal elevation constant of water evaporates at 100C with the absorption of 536 (R = 2 cals) calories per gm (a) 0.519C (b) 0.0519C (c) 1.519C (d) 2.519C
-
g(x) = x 5 5x 6 a. Show that g(x) = 0 has a root, , between x = 1 and x = 2. b. Show that the equation g(x) = 0 can be written as x = (px + q) 1/r , where p, q and r are integers to be found. The...
-
Fill in the blank(s) in each of the following statements: a) Lists and tables of values can be stored in _______. b) An array is a group of _______(called elements) containing values that all have...
-
What does the following code display? Console.WriteLine("*"); Console.WriteLine("***"); Console.WriteLine("*****"); Console.WriteLine("****"); Console.WriteLine("**");
-
For the class Craps in Fig. 7.8, state the scope of each of the following entities: a) The variable random Numbers. b) The variable die 1. c) The method Roll Dice. d) The method Main. e) The variable...
-
A prototype can be ___________. (a) Complete system with partial requirements (b) Working model (c) Full-fledged system (d) All of these
-
_____________ is also used as requirement finding and feasibility testing tool. (a) Prototype (b) Reports (c) System (d) Procedure
-
Which of the following systems development approach is adopted if information requirements are not well defined? (a) SDLC (b) Prototype (c) Structured approach (d) Agile
Study smarter with the SolutionInn App