Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use Python to create some reports based on trench depth data that you read from a CSV file Trench_Depths.csv. The data in the file is

Use Python to create some reports based on trench depth data that you read from a CSV file Trench_Depths.csv. The data in the file is in the form: , (a string followed by an integer) FYI, the depths are given in meters.

Steps that need to be done:

1.) Create a fruitful function called file_to_dictionary(file_name) that reads trench data from the given file, and it creates a dictionary of name:depth pairs. The names will be strings; the depths will be integers. The function returns the dictionary that it creates. Your program should deal with a missing file appropriately.

2.) Create a function called display_by_name(dict) that displays the dictionary sorted alphabetically by trench name. The function should properly title the report.

3.) Create a function called display_by_depth(dict) that displays the dictionary sorted numerically in descending order by depth. This report should also display the depths in feet. You may use the fact that one meter is approximately 3.28 feet. The function should properly title the report.

4.) Create a function called display_by_length(dict) that displays the dictionary sorted in ascending order by the lengths of the trench names. The function should properly title the report.

5.) Create a fruitful function called menu() that implements a menu system that repeatedly asks the user for input. The inputs should be a single character specifying which action the user requires: N=display by name, D=display by depth, L=display by length, Q=quit the program. Input characters may be in uppercase or lowercase. Your program should deal with invalid requests appropriately. menu() should return the command character in uppercase to its caller.

6.) Create a main driver that repeatedly calls menu() to acquire user commands and then execute them. It should loop until the quit command is issued.

7.) You must do your final run (for submission) using Thonnys Run | Run current script in terminal command. Alternatively, you can just run your program directly from Windows by double-clicking on your Python .py program file.

8.) Your program should clear the output window before each repetition begins to achieve the effect shown below. To accomplish this, you must import os and then use the command: os.system('cls') to clear the screen.

Hint: You may find that when sorting your dictionary and then displaying it in sorted form that it is convenient to recreate the data in some other form such as a list before doing the printing.

Hint: Your runtime output is not required to match what is shown below. But the content of each display must meet the requirements of the assignment regarding what is to be displayed. Your final run must display all the data contained in Trench_Depths.csv, not just the fragment shown in the Sample Output.

FYI: The data provided in Trench_Depths.csv was extracted from: https://en.wikipedia.org/wiki/Oceanic_trench https://en.wikipedia.org/wiki/List_of_submarine_topographical_features

SAMPLE OUTPUT

image text in transcribedimage text in transcribed

When the program first starts: Trench Report Control N=Displaydataby(N)ameD=Displaydataby(D)epth L= Display data by Name (L)ength Q= Quit (terminate) NDLQ: Trench Data Sorted by Name

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: 3

blur-text-image

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

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions

Question

Evaluate the expression. 8 P 0

Answered: 1 week ago

Question

Distinguish between hearing and listening.

Answered: 1 week ago

Question

Use your voice effectively.

Answered: 1 week ago