asd
unknown
python
2 years ago
1.6 kB
1
Indexable
Never
import math deprem = input("Please enter the dataset: ") aranan = input("Please enter the earthquake that you want to look for: ") km = float(input("Please enter the radius (in km): ")) if aranan not in deprem: print (aranan, "is not in the database.") deprem = deprem.replace(":", ",") deprem = deprem.replace(";", ",") mylist = deprem.split(",") index = mylist.index(aranan) print("For the earthquake", aranan, "; following(s) are the foreshocks and aftershocks:") print("----------------------------------------------------------------------------") shock = [] i = 1 while i in range(len(mylist)): if int(mylist[index+1])-86400 < int(mylist[i]) < int(mylist[index+1])+86400: shock.append(mylist[i-1]) if aranan in shock: shock.remove(aranan) #print("* Earthquake", mylist[i - 1], "with latitude", mylist[i + 1], "and longitude", mylist[i + 2] + ".") i += 4 if len(shock) <= 0: print("pipi") z = 0 while z in range(len(mylist)): iq = mylist.index(aranan) for j in shock: if j in mylist: ix = mylist.index(j) distance = 100*math.sqrt((float(mylist[iq + 3]) - float(mylist[ix + 3]))**2 + (float(mylist[iq + 2]) - float(mylist[ix + 2]))**2) if distance > km: shock.remove(j) z += 4 for i in shock: if i in mylist: ix = mylist.index(i) print("* Earthquake", mylist[ix], "with latitude", mylist[ix + 2], "and longitude", mylist[ix + 3] + ".") #print (shock)