Question: Goal: Learn to read and process files containing raw data. Assignment: Assume the file numbers.txt contains a series of numbers. Write a program that calculates

Goal: Learn to read and process files containing raw data.
Assignment: Assume the file numbers.txt contains a series of numbers. Write a program that calculates the average of all the negative numbers and the average of all the positive numbers, and then prints both to the screen. If there are no numbers (i.e. no negative numbers and/or no positive numbers), print NaN instead.
Print only the averages, first the negative and then the positive, with no formatting
is separated from the next by a line with a dash. The following is an example file:
Contents of units.txt
10
123
95
285
64
Write some code that creates a file named totals. txt in which each line is the sum of all the item counts per container section. Continuing the above example,
the following is the example result:
Contents of totals.txt
228
349

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!