Question: Starting out with Python 3E Chapter 6. PC #5 and #6 Combine Chapter 6. PC #5 and #6 Combined and modified. Homework Assignment (read instructions

Starting out with Python 3E Chapter 6. PC #5 and #6 Combine

Chapter 6. PC #5 and #6 Combined and modified. Homework Assignment (read instructions carefully) Write a program that asks the user for the name of a file. Assume that the file contains a series of integers, one on each line. The program should read all the numbers from the given file, calculate their total and average, and then display the total and average of all numbers in the following format (three decimal digits):

Test Case 1

Standard Input Files in the same directory
input1.txt

input1.txt

input2.txt

input3.txt

input4.txt

Please enter the file name or type QUIT to exit: Total: 11.800 Average: 2.950 

Test Case 2

Standard Input Files in the same directory
input2.txt

input1.txt

input2.txt

input3.txt

input4.txt

Please enter the file name or type QUIT to exit: Total: 17.300 Average: 3.460 

Test Case 3

Standard Input Files in the same directory
input3.txt

input1.txt

input2.txt

input3.txt

input4.txt

Please enter the file name or type QUIT to exit: Total: 1.124 Average: 1.124 

Test Case 4

Standard Input Files in the same directory
input4.txt

input1.txt

input2.txt

input3.txt

input4.txt

Please enter the file name or type QUIT to exit: File input4.txt is empty. 

Test Case 5

Standard Input Files in the same directory
input5.txtENTER input1.txt

input1.txt

input2.txt

input3.txt

input4.txt

Please enter the file name or type QUIT to exit: File: input5.txt does not exist. Please enter the file name again or type QUIT to exit: Total: 11.800 Average: 2.950 

Test Case 6

Standard Input Files in the same directory
qUiT

input1.txt

input2.txt

input3.txt

input4.txt

Please enter the file name or type QUIT to exit: 

Test Case 7

Standard Input Files in the same directory
input5.txtENTER QuiT

input1.txt

input2.txt

input3.txt

input4.txt

Please enter the file name or type QUIT to exit: File: input5.txt does not exist. Please enter the file name again or type QUIT to exit: 

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!