Question: Design a program in which numeric data is read from a file and processed. Data file packages.txt. The file contains some number of package weights,

Design a program in which numeric data is read from a file and processed. Data file packages.txt. The file contains some number of package weights, one per line. Open and read the file using a for loop to process all the weights. Code must work for any data set. Report the number of packages entered and average weight of each category of package based on the classifications below.

packages.txt :

11 25 12 82 20 25 32 35 40 28 50 51 18 48 90

o Hint: you will need three counters and three sums. If no packages of a weight class are entered, report the message N/A instead of an average (if you try to divide by 0 you will get an exception).

o The average should display one decimal place.

o Use string format zones for output to neatly align the columns.

Design a program in which numeric data is read from a file o Category Weight Limit Small = 10 lbs. and = 30 lbs.

COS-120 [C:Users micha PycharmProjects\coS-120] packages.py [COS-1.. File Edit View Navigate Code Refactor Run Iools VCS Window Help COS-120 packages.py packages a packages C: \Users micha venv\COS-120\Scripts\python.exe C:/Users/micha t Run: Category Small Medium Large Count 0 7 Average N/A 19.9 53.5 Process finished with exit code 0 5: Debug Terminal -Python Console QEvent Log 4: Run := 6: TO DO 8:20 CRLP: UTF-8

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 Databases Questions!