Question: You will write a function to access a file of earthquake data and create a list of the magnitudes of the earthquakes in the file,

You will 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 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 = 'equakes25f.txt'

fname = 'equakes50f.txt'

#fname = 'equakes_short.txt'

emags = equake_readf(fname)

mmm = equake_analysis(emags)

equake_report(emags, mmm)

return None

Include code in your .py file to call the main function.

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!