Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using IDLE 3.6: https://www.python.org/ftp/python/3.6.2/python-3.6.2.exe Write a program using python in IDLE which allows the user to read a list of numbers from a data file.

using IDLE 3.6:

https://www.python.org/ftp/python/3.6.2/python-3.6.2.exe

Write a program using python in IDLE which allows the user to read a list of numbers from a data file. If the user specifies a data file which does not currently exist, then the program will create it. The program should present the user with a menu containing the following options:

Current data file being processed.

(1) Select / create data file (.txt file extension will be added automatically)

(2) Display all the numbers in the data file, along with their total and average

(3) Display all the numbers in the data file sorted from smallest to largest

(4) Search for a number in the data file and display how many times the number occurs in the file

(5) Display the largest number in the data file

(6) Append one or more random numbers to the data file

(6) Append one or more random numbers to the data file

(7) Exit the program

Prompt the user to make a selection from the menu and use input validation to ensure the user makes a valid selection (1 - 7).

Use if/elif statements to process each of the above options. Each option should call a function which carries out the required action.

When asking the user which data file they wish to process, ask the user to only enter the part of the filename preceding the .txt extension and automatically add the .txt extension for the user. Create an empty data file if the file does not already exist.

Options (2) - (6) should test whether a data file has been specified before calling the function. If a data file has not yet been specified, the option should not call the function and the display should be refreshed.

When a data file is first created it will be empty. The functions which process the data file will need to handle the special case when the file exists, but does not contain any numbers. To make the program easier to write, you may opt to ignore this special case and assume that the user will immediately add numbers to the file once it has been created.

When adding a number(s), append it to the end of the data file.

A good approach to working on this project is to write the code for the easiest menu options first.

**** Global variables are NOT allowed. ****

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

CAWINDOWS py.exe urrent Data File (1) Select / create data file c.txt file extension will be added automatically) (2) Display all numbers,total and average 3) Display all numbers sorted (4) Search for a number and display how many times it occurs (5) Display the largest number (6) Append a random number(s) 7) Exit the program enu choice: 8 Press any key to continue: Menu choice: e Press any key to continue: Menu choice: 1 ame of data file: MyFile File not found, creating file Press any key to continue: ?CAWINDOWS\py.exe MENU urrent Data File: MyFile (1) Select/create data file ( txt file extension will be added automatically) (2) Display all numbers, total and average (3) Display all numbers sorted (4) Search for a number and display how many times it occurs (5) Display the largest number (6) Append a random number(s) (7) Exit the program enu choice: 2 ata file is empty ile Successfully Read Press any key to continue

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_2

Step: 3

blur-text-image_3

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

Database Internals A Deep Dive Into How Distributed Data Systems Work

Authors: Alex Petrov

1st Edition

1492040347, 978-1492040347

More Books

Students also viewed these Databases questions

Question

=+Identify trends in the social media industry

Answered: 1 week ago