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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started