asd
unknown
python
2 years ago
2.0 kB
1
Indexable
Never
import math deprem = input("Please enter the dataset: ") deprem = deprem.replace(":", ",") deprem = deprem.replace(";", ",") mylist = deprem.split(",") isimList = [] a = 0 while a < len(mylist): isimList.append(mylist[a]) a+=4 aranan = input("Please enter the earthquake that you want to look for: ") km = float(input("Please enter the radius (in km): ")) a = ("For the earthquake " + aranan + "; following(s) are the foreshocks and aftershocks:") a = str(a) if aranan not in isimList or aranan not in mylist: print(aranan, "is not in the database.") #if aranan not in mylist: # print(aranan, "is not in the database.") else: index = mylist.index(aranan) 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) i += 4 if len(shock) <= 0: print("There were no foreshocks and aftershocks after the earthquake", aranan + ".") else: print("For the earthquake", aranan + "; following(s) are the foreshocks and aftershocks:") print("-" * len(a)) 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", format(float(mylist[ix + 2]), '.2f'), "and longitude", format(float(mylist[ix + 3]), '.2f') + ".")