Capital Cities Near a Latitude

What Your Function Should Do

Write a function NearestCapitalByLatitude that takes a latitude lat and returns the capital city of a country whose latitude is closest to lat. Use the (HyperlinkTemplate["Entity", paclet:ref/Entity, paclet:ref/Entity, Link, HyperlinkActive, ]) type "Country" to find the capital cities.

NearestCapitalByLatitude[40]

NearestCapitalByLatitude[0]

NearestCapitalByLatitude[38]

Here is the 38th parallel with Athens:

More Examples

Here is the latitude for Paris:

(Entity["Paris", Entity["City",{"Paris","IleDeFrance","France"}], "Entity[\"City\", {\"Paris\", \"IleDeFrance\", \"France\"}]", "city"])["Latitude"]

The nearest capital city to this latitude is:

NearestCapitalByLatitude[48.86]

NearestCapitalByLatitude[lat_]/;-90≤lat≤90:=