lab 6 files earthquakes

Ace your studies with our custom writing services! We've got your back for top grades and timely submissions, so you can say goodbye to the stress. Trust us to get you there!


Order a Similar Paper Order a Different Paper

Assignment

  • 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. https://think.cs.vt.edu/corgis/csv/earthquakes/
  • Download lab6.py 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_
_x000D_
# The missing functions go here._x000D_
_x000D_
# --------------------------------------_x000D_
_x000D_
def main(file_name):_x000D_
    magnitude = average_magnitude(file_name)_x000D_
    print("The average earthquake magnitude is {:.2f}n".format(magnitude))_x000D_
    _x000D_
    earthquake_locations(file_name)_x000D_
    _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_
# --------------------------------------_x000D_
 

main(“earthquakes.csv”)

Writerbay.net

Looking for top-notch essay writing services? We've got you covered! Connect with our writing experts today. Placing your order is easy, taking less than 5 minutes. Click below to get started.


Order a Similar Paper Order a Different Paper