Question
Please help me with this question. Many thanks Using python codes Trench Depths, Direct Measure The deepest locations on earth are at the bottom of
Please help me with this question. Many thanks
Using python codes
Trench Depths, Direct Measure The deepest locations on earth are at the bottom of ocean trenches. In this assignment you will 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. Here are the things you need to do: 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: Wikipedia: Oceanic Trench Wikipedia: Submarine topographical features Run your program several times using different inputs
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