lab 6 files earthquakes

Get perfect grades by consistently using writing services. Place your order and get a quality paper today. Take advantage of our current 20% discount by using the coupon code GET20

Order a Similar Paper Order a Different Paper


  • Hint: You’ll be using file of comma separated values, yet a comma appears in one of the values itself (location.full field). That can mess up the split(‘,’) function because some of the values you need to use come after that location.full column, which has the occasional comma. The hint is to go at it from the other direction. None of the columns after the location.full field have commas in the values. Remember that you can use a negative number to index into a list from the other end rather than the beginning.
  • Download the file earthquakes.csv. This input file is described in detail here.
  • Download into the same directory where the earthquakes.csv file is located and rename it according to the instructions in the Logistics section.
  • Implement the average_magnitude function such that it calculates and returns the average magnitude of the recorded earthquakes.
  • Implement the earthquake_locations function such that it identifies every unique location (use the name field in the file) and prints them in alphabetical order.
  • Implement the count_earthquakes function. The function should calculate the number of recorded earthquakes that have a magnitude greater than or equal to the low bound and less than or equal to the high bound. The user will specify the bounds and you may assume that the user will enter valid numbers.

Sample Run

  • In this sample run, the user inputs 5.0 for the lower bound and 6.0 for the upper bound.

Grading – 10 points

  • 2 points – The average_magnitude function is correct.
  • 3 points – The earthquake_locations function finds all of the unique locations (2 points) and prints each unique location once in sorted order (1 point).
  • 3 points – The count_earthquakes function is correct. The function will be tested on a different case that will be revealed after the lab is submitted.
  • 2 points – The format of the output matches exactly the format of the output transcript. For each type of difference, 1 point will be deducted.

Download LAB 6

# --------------------------------------_x000D_
# CSCI 127, Lab 6                      |_x000D_
# February 27, 2020                    |_x000D_
# Your Name                            |_x000D_
# --------------------------------------_x000D_
# The missing functions go here._x000D_
# --------------------------------------_x000D_
def main(file_name):_x000D_
    magnitude = average_magnitude(file_name)_x000D_
    print("The average earthquake magnitude is {:.2f}n".format(magnitude))_x000D_
    lower_bound = float(input("Enter a lower bound for the magnitude: "))_x000D_
    upper_bound = float(input("Enter an upper bound for the magnitude: "))_x000D_
    how_many = count_earthquakes(file_name, lower_bound, upper_bound)_x000D_
    print("Number of recorded earthquakes between {:.2f} and {:.2f} = {:d}".format(lower_bound, upper_bound, how_many))_x000D_
# --------------------------------------_x000D_


Do you need help with this or a different assignment? We offer CONFIDENTIAL, ORIGINAL (Turnitin/LopesWrite/SafeAssign checks), and PRIVATE services using latest (within 5 years) peer-reviewed articles. Kindly click on ORDER NOW to receive an A++ paper from our masters- and PhD writers.

Get a 15% discount on your order using the following coupon code SAVE15

Order a Similar Paper Order a Different Paper