Another gray seal, Gracie, has also been tracked recently. Her latitude and longitude were recorded in 2014, and her listed travels in that year are: lat = (40.59, 40.52, 40.621, 40.519, 40.56, 41.265, 40.61, 40.806, 41.259, 41.265, 41.264, 41.264, 41.259, 41.262, 41.263) lon = (69.532, 69.419, 69.354, 69.263, 69.478, 70.805, 69.706, 70.331, 70.815, 70.823, 70.815, 70.81, 70.824, 70.811, 70.811) Write a program to find the farthest north, west, south, and east she went.
Answers
Answer:
So latitude goes from -90 being the most southern point in the world, to +90 being the northernmost point. Longitude goes from -180 (west) to +180 (east).
Here is a program to find the 4 things you desired. Since both of these lists are of length 15, one loop can iterate through both of them.
Program:
#First we initialise the variables you are looking to find, with the first variable from the lists, to give them something to compare to
northmost=lat[0]
southmost=lat[0]
westmost=lon[0]
eastmost=lon[0]
for x in range(15):
if(lat[x]>northmost):
northmost=lat[x]
if(lat[x]<southmost):
southmost=lat[x]
if(lon[x]<westmost):
westmost=lon[x]
if(lon[x]>eastmost):
eastmost=lon[x]
Explanation:
Essentially you are just comparing each item in the list to the the minimum and maximum value of the list so far.