Skip to content

Latest commit

 

History

History
 
 

Distance Finder

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 


Prettier License

Description:

  • Let's look at a Python script that calculates the distance between two locations.
  • It accepts two cities as input and calculates longitude and latitude for them.
  • Finally, the result will be displayed in kilometres.

Procedure to follow:

      from geopy.geocoders import Nominatim 
      from geopy.distance import geodesic 
  • Set the user agent where all the data will be fetched using the Nominatim function; in our example, it'll be Google Map.
  • Take the user's input for two cities.
  • Now, using geocode, retrieve all of the data, including all of the city's details, such as latitude, longitude, and so on.
  • Both cities longitude and latitude should be saved in separate variables.
  • Use geodesic to determine the city's name based on its longi and lati.
  • Finally, in kilometers, display the result.

Sample Output:

hey