Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Open a new Python editor window. Save it with the name p72_equakes.py. Download the 'p72-equakes-50f-2019.csv' and 'p72-equakes-25f-2019.csv'files (with data for earthquakes of magnitude 5.0 or

image text in transcribedimage text in transcribed

image text in transcribed

Open a new Python editor window. Save it with the name p72_equakes.py. Download the 'p72-equakes-50f-2019.csv' and 'p72-equakes-25f-2019.csv'files (with data for earthquakes of magnitude 5.0 or higher and magnitude 2.5 or higher, respectively) and save them in the same folder as your p72_equakes.py file. You may also want to create short versions of the equakes files for testing your code and experimenting with files in the Python Shell. The data in the earthquake files is structured like this: time,latitude,longitude,depth, mag,magType,nst,gap,dmin,rms,net,id, updated, place, type, horizontal Error,depthError,magError,magNst,status,locationSource, magSource 2010-07-28T16:12:05.6102,43.756,-125.815,10,5.2,mwc,193,143.9,0.93,us,usp000hhot,2017- 08-01T16:34:36.9512,"off the coast of Oregon", earthquake,,,,,reviewed us,gemt 1993-12-04T22:15:19.7202,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 The first line of the file is a header, which gives the meaning of each field (column) of the data. Challenge We might prefer to see the earthquakes listed with the biggest magnitude first. Revise your code so that earthquake data is reported this way (biggest magnitude first). Hint: the list sort method (and the sorted function) have an optional default argument, reverse. When reverse is true, the list is sorted in descending rather than descending order. For example: >>> li = [2, 3, 1] >>> li.sort () >>> li [1, 2, 3] >>> li.sort (reverse=True) >>> li [3, 2, 1] Further considerations: re-execute your code from project 7-1 (count majors). How has it been impacted by these revisions? Is this ok? If not, use this to start thinking about considerations for writing code that may be re-used. mag time latitude longitude depth 2010-07-28 43.756 125.815 10 1993-12-04 42.2915 -122.009 4.797 1993-09-21 42.3675 -122.058 8.53 1993-09-21 42.31617-122 027 8.56 1993-03-28 46.03617 122.607 19.600 1980-06-18 46.20733 -122.188 1.51 1980-04-22 46.20267.122.182 -0.523 1980-04-18 46.208 122.183 0.223 1980-04-14 46.2035 122.197 0.515 1980-04-08 46.20983 122.196 0.561 1976-12-15 42.752 125.603 15 1975-07-28 43.687 126.103 33 1973-06-16 44.98 125.774 1962-11-06 45.642-122.588 16 1961-09-17 46.023 122 122 7 1960-11-06 44.9 125.2 1953-12-16 45.5 -122.7 1938-08-03 43.9 - 126.2 magType nist 5.2 mwe 5.1 md 6 md 5.9 md 5.6 md 5.7 md 5 md 5 md 5.2 md 5.1 md 5.6 mb 5.2 mb 5.6 mb 5.18 m 5.1 ml 5 ml gap dmin mms 193 143.9 126 113 234 128 201 129 40 67 0.2067 18 62 0.008296 21 57 0.03886 22 59 0.04013 21 55 0.0289 19 63 0.03256 net 0.93 us 0.11 Uw 0.08 uw 0.09 uw 0.39 0.22 uw 0.18 W 0.19 W 0.19 uw 0.39 w us us id updated place type horizontale depthError magError magNst status location Sou mag Source usp000hho 2017-08-01 off the coa: earthquake reviewed us gemt uw 1031642017-04-13 Oregon earthquake 0.468 0.56 0.04 7 reviewed ww Uw uw 103138:2018-02-23 Oregon earthquake 0.4 0.85 0.02 3 reviewed w uw uw 10313712018-01-16 Oregon earthquake 0.441 0.93 0.02 3 reviewed ww uw uw 10306312017.05.10 Oregon earthquake 0.934 2.84 2 reviewed uw uw uw 100848C 2018-06-04 Mount St. Fearthquake 0.682 0.56 0.00 1 reviewed ww uw uw 10064512018-06-04 Mount St. Fearthquake 0.439 0.62 0.07 1 reviewed uw uw uw 100824 2018-06-04 Mount St. Fearthquake 0.46 0.73 0.00 1 reviewed ww uw uw 100808(2018-06-04 Mount St. Fearthquake 0.042 0.05 0.13 1 reviewed uw uw uw 10077952016-07-24 Mount St. Fearthquake 1.374 1.85 0.07 1 reviewed ww UW usp0000ku 2014-11-0 offshore Or earthquake reviewed us US Sp0000c7 2014-11-0 off the coat earthquake reviewed us usp000026 2018-06-04 off the coat earthquake reviewed us ushis2577 2018-06-04 Portland ur earthquake reviewed ushis ushis2517 2018-06-04 Washingtor earthquake reviewed ushis gw ushis 2469 2018-06-04 offshore or earthquake reviewed ushis brk ushis 1907 2018-06-04 Portland ur earthquake reviewed ushis epb ushis 1206 2018-06-04 off the coat earthquake reviewed ushis gr ushis ushis ushis ushis ushis 5 uk 5.6 ms Open a new Python editor window. Save it with the name p72_equakes.py. Download the 'p72-equakes-50f-2019.csv' and 'p72-equakes-25f-2019.csv'files (with data for earthquakes of magnitude 5.0 or higher and magnitude 2.5 or higher, respectively) and save them in the same folder as your p72_equakes.py file. You may also want to create short versions of the equakes files for testing your code and experimenting with files in the Python Shell. The data in the earthquake files is structured like this: time,latitude,longitude,depth, mag,magType,nst,gap,dmin,rms,net,id, updated, place, type, horizontal Error,depthError,magError,magNst,status,locationSource, magSource 2010-07-28T16:12:05.6102,43.756,-125.815,10,5.2,mwc,193,143.9,0.93,us,usp000hhot,2017- 08-01T16:34:36.9512,"off the coast of Oregon", earthquake,,,,,reviewed us,gemt 1993-12-04T22:15:19.7202,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 The first line of the file is a header, which gives the meaning of each field (column) of the data. Challenge We might prefer to see the earthquakes listed with the biggest magnitude first. Revise your code so that earthquake data is reported this way (biggest magnitude first). Hint: the list sort method (and the sorted function) have an optional default argument, reverse. When reverse is true, the list is sorted in descending rather than descending order. For example: >>> li = [2, 3, 1] >>> li.sort () >>> li [1, 2, 3] >>> li.sort (reverse=True) >>> li [3, 2, 1] Further considerations: re-execute your code from project 7-1 (count majors). How has it been impacted by these revisions? Is this ok? If not, use this to start thinking about considerations for writing code that may be re-used. mag time latitude longitude depth 2010-07-28 43.756 125.815 10 1993-12-04 42.2915 -122.009 4.797 1993-09-21 42.3675 -122.058 8.53 1993-09-21 42.31617-122 027 8.56 1993-03-28 46.03617 122.607 19.600 1980-06-18 46.20733 -122.188 1.51 1980-04-22 46.20267.122.182 -0.523 1980-04-18 46.208 122.183 0.223 1980-04-14 46.2035 122.197 0.515 1980-04-08 46.20983 122.196 0.561 1976-12-15 42.752 125.603 15 1975-07-28 43.687 126.103 33 1973-06-16 44.98 125.774 1962-11-06 45.642-122.588 16 1961-09-17 46.023 122 122 7 1960-11-06 44.9 125.2 1953-12-16 45.5 -122.7 1938-08-03 43.9 - 126.2 magType nist 5.2 mwe 5.1 md 6 md 5.9 md 5.6 md 5.7 md 5 md 5 md 5.2 md 5.1 md 5.6 mb 5.2 mb 5.6 mb 5.18 m 5.1 ml 5 ml gap dmin mms 193 143.9 126 113 234 128 201 129 40 67 0.2067 18 62 0.008296 21 57 0.03886 22 59 0.04013 21 55 0.0289 19 63 0.03256 net 0.93 us 0.11 Uw 0.08 uw 0.09 uw 0.39 0.22 uw 0.18 W 0.19 W 0.19 uw 0.39 w us us id updated place type horizontale depthError magError magNst status location Sou mag Source usp000hho 2017-08-01 off the coa: earthquake reviewed us gemt uw 1031642017-04-13 Oregon earthquake 0.468 0.56 0.04 7 reviewed ww Uw uw 103138:2018-02-23 Oregon earthquake 0.4 0.85 0.02 3 reviewed w uw uw 10313712018-01-16 Oregon earthquake 0.441 0.93 0.02 3 reviewed ww uw uw 10306312017.05.10 Oregon earthquake 0.934 2.84 2 reviewed uw uw uw 100848C 2018-06-04 Mount St. Fearthquake 0.682 0.56 0.00 1 reviewed ww uw uw 10064512018-06-04 Mount St. Fearthquake 0.439 0.62 0.07 1 reviewed uw uw uw 100824 2018-06-04 Mount St. Fearthquake 0.46 0.73 0.00 1 reviewed ww uw uw 100808(2018-06-04 Mount St. Fearthquake 0.042 0.05 0.13 1 reviewed uw uw uw 10077952016-07-24 Mount St. Fearthquake 1.374 1.85 0.07 1 reviewed ww UW usp0000ku 2014-11-0 offshore Or earthquake reviewed us US Sp0000c7 2014-11-0 off the coat earthquake reviewed us usp000026 2018-06-04 off the coat earthquake reviewed us ushis2577 2018-06-04 Portland ur earthquake reviewed ushis ushis2517 2018-06-04 Washingtor earthquake reviewed ushis gw ushis 2469 2018-06-04 offshore or earthquake reviewed ushis brk ushis 1907 2018-06-04 Portland ur earthquake reviewed ushis epb ushis 1206 2018-06-04 off the coat earthquake reviewed ushis gr ushis ushis ushis ushis ushis 5 uk 5.6 ms

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

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago