Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Here is some data on earthquakes of magnitude 2.5+ that occurred in the past 7 d

ID: 664267 • Letter: H

Question

Here is some data on earthquakes of magnitude 2.5+ that occurred in the past 7 days:
http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_week.csv
It is a comma separated csv formatted text file with basic earthquake information such as source of earthquake (src), date, region etc.

Write a function earthquakeInfo(src) which returns the total number of earthquakes that took place in the last 7 days, the number of earthquakes that took place yesterday and the number of earthquakes that originated at src For example,

>>>earthquakeInfo(“ak”) Today’s Date: 2012-02-24
Total number of Earthquakes past 7 days: 205
Earthquakes yesterday 2012-02-23: 26
Earthquakes with source ak: 96

>>>earthquakeInfo(“us”) Today’s Date: 2012-02-24
Total number of Earthquakes past 7 days: 205
Earthquakes yesterday 2012-02-23: 26
Earthquake with source us: 75


Should be in Python, tested and working

Explanation / Answer

import csv

filename = 'http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_week.csv'

latitude, longitude, id = [], [], []

depth,nst,gap,dmin,rms,net,updated,mag = [], [], [], [], [], [], [], []

magnitudes, time,magType,place,type = [], [], [], [], []

with open(filename, 'rb') as f:

    reader = csv.reader(f)

    # ignore header row

    reader.next()

    for row in reader:

        latitude.append(float(row[4]))

        longitude.append(float(row[5]))

        magnitudes.append(float(row[6]))

        time.append(row[3])
        id.append(float(row[4]))

        depth.append(float(row[4]))

        gap.append(float(row[7]))
        dmin.append(float(row[7]))
        rms.append(float(row[6]))
        net.append(float(row[6]))
        updated.append(float(row[7]))
        mag.append(float(row[8]))
         magType.append(float(row[8]))
     
        place.append(float(row[8]))

        type.append(float(row[8]))

      

     

       

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote