Question: Write a function to access a file of earthquake data and create a list of the magnitudes of the earthquakes in the file, then another

Write a function to access a file of earthquake data and create a list of the magnitudes of the earthquakes in the file, then another function to analyze the magnitudes data. Finally, you will write a function to report the count, mean, median, mode, and frequency occurrences of the earthquake magnitudes.

Write a function to access a file of earthquake data and create

WHAT THE DATA FORMAT IN THE TEXT FILE LOOKS LIKE IN: equake25f.txt

time,latitude,longitude,depth,mag,magType,nst,gap,dmin,rms,net,id,updated,place,type,horizontalError,depthError,magError,magNst,status,locationSource,magSource 2017-10-16T05:28:09.430Z,45.9166667,-123.4611667,24.31,3.38,ml,43,46,0.06977,0.22,uw,uw61342436,2017-10-24T22:18:47.140Z,"21km WNW of Vernonia, Oregon",earthquake,0.3,0.82,0.201,26,reviewed,uw,uw 2017-10-10T02:45:37.050Z,45.3206667,-121.6861667,6.84,2.75,ml,25,45,0.02276,0.16,uw,uw61339596,2017-10-11T02:48:18.819Z,"23km E of Mount Hood Village, Oregon",earthquake,0.24,0.23,0.188,23,reviewed,uw,uw 2017-09-26T22:21:58.680Z,44.2518333,-123.9531667,24.14,2.77,ml,20,98,0.1208,0.28,uw,uw61311237,2017-10-26T05:41:15.040Z,"21km SSE of Waldport, Oregon",earthquake,0.45,1.16,0.136,14,reviewed,uw,uw 2017-09-05T15:48:09.530Z,44.3418333,-124.4218333,25.72,2.82,ml,13,248,0.235,0.21,uw,uw61303577,2017-09-08T21:02:11.102Z,"24km WSW of Waldport, Oregon",earthquake,1.56,0.96,0.285,7,reviewed,uw,uw 
(^^^ AND IT GOES ON LIKE THIS FOR HUNDREDS OF LINES ^^^) 

WHAT THE DATA LOOKS LIKE IN: equake50f.txt

time,latitude,longitude,depth,mag,magType,nst,gap,dmin,rms,net,id,updated,place,type,horizontalError,depthError,magError,magNst,status,locationSource,magSource 2010-07-28T16:12:05.610Z,43.756,-125.815,10,5.2,mwc,193,143.9,,0.93,us,usp000hh0t,2017-08-01T16:34:36.951Z,"off the coast of Oregon",earthquake,,,,,reviewed,us,gcmt 1993-12-04T22:15:19.720Z,42.2915,-122.0086667,4.797,5.1,md,126,113,,0.11,uw,uw10316468,2017-04-13T22:06:07.852Z,"Oregon",earthquake,0.468,0.56,0.04,7,reviewed,uw,uw (^^^ AND IT GOES ON LIKE THIS FOR A FEW MORE LINES ^^^) 

Write three new functions: equake_readf, equake_analysis, and equake_report. Function equake_readf will have one parameter, fname, a string, which is the name of the earthquake file. equake_readf should open file fname and create and return a list of the earthquake magnitudes from this file Function equake analysis will have one parameter, magnitudes, the list of earthquake magnitudes (the list returned by equake_readf). equake_analysis will call functions from the data analysis file (project 6-2) to determine the mean, median, and mode of the data in the magnitudes list, and then return this result as a tuple Function equake_report will have two parameters, mmm (the tuple returned by equake analysis) and magnitudes (the list returned by equake readf), and return None. It will report the number (count) of earthquakes, and the mean, median, and mode of magnitudes. It will also call frequencyTable to report the number of occurrences of each item in magnitudes. When you have written and tested these, write function main to call functions equake readf, equake analysis, and equake report. main returns None main should look similar to this def main): '')-> None Calls: equake_readf, equake_analysis, equake_report Top level function for earthquake data analysis. Returns None. #fname- ' equakes 50 f . txt ' fname = 'equakes25f.txt' #fname = 'equakes. Short. txt' emags = eguake-readf(fname) mmm = equake-analysis (emags) equake_report (emags, mmm) return None Write three new functions: equake_readf, equake_analysis, and equake_report. Function equake_readf will have one parameter, fname, a string, which is the name of the earthquake file. equake_readf should open file fname and create and return a list of the earthquake magnitudes from this file Function equake analysis will have one parameter, magnitudes, the list of earthquake magnitudes (the list returned by equake_readf). equake_analysis will call functions from the data analysis file (project 6-2) to determine the mean, median, and mode of the data in the magnitudes list, and then return this result as a tuple Function equake_report will have two parameters, mmm (the tuple returned by equake analysis) and magnitudes (the list returned by equake readf), and return None. It will report the number (count) of earthquakes, and the mean, median, and mode of magnitudes. It will also call frequencyTable to report the number of occurrences of each item in magnitudes. When you have written and tested these, write function main to call functions equake readf, equake analysis, and equake report. main returns None main should look similar to this def main): '')-> None Calls: equake_readf, equake_analysis, equake_report Top level function for earthquake data analysis. Returns None. #fname- ' equakes 50 f . txt ' fname = 'equakes25f.txt' #fname = 'equakes. Short. txt' emags = eguake-readf(fname) mmm = equake-analysis (emags) equake_report (emags, mmm) return None

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!