Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Python: Part 1: Ask for a file name. The file should exist in the same folder as the program. If using input() to receive

Using Python:

Part 1: Ask for a file name. The file should exist in the same folder as the program. If using input() to receive the file name do not give it a path, just give it a name like number1.txt or something similar (without the quotes when you enter the name). Then ask for test scores (0-100) until the user enters a specific value, in this case, -1. Write each value to the file as it has been entered. Make sure to close the file once the user has finished entering in the data.

Specifics: You can use input() or FileUtils.selectOpenFile/FileUtils.selectSaveFile for receiving the file name from the user in either part. Entering no actual data is legal (after entering a file name) and should be considered in part 1 and part 2.

Part 2: (separate file) Ask for a file name. Dont let the program crash if you enter the name of a file that does not exist. Gracefully display an error message stating the file doesnt exist and quit the program. Read all the values in the file. You will only read the file once, or more to the point, only read the file once. After the program has finished reading all the data, display the following information to the screen:

The minimum value

The maximum value

The average display with 3 places after the decimal point

The total number of values

The total number of values greater than or equal to 70

The total number of values less than 70

The value closest to 70 (can be 70, less than 70 or greater than 70)

The value closest to 70 WITHOUT going over 70 (can be 70, WILL NOT be greater than 70)

If no data exists in the file, write out a simple message indicating that there was no data in the file and nothing else.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions