Skip to content

Commit 0bbe184

Browse files
committed
Adding hints
1 parent 20e6c62 commit 0bbe184

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

haversine_calculation/haversine.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
import math
22

33

4-
def haversine(lat1, lon1, lat2, lon2):
4+
def haversine(lat1: float, lon1: float, lat2: float, lon2: float) -> float:
55
"""
6-
Calculate the great circle distance in kilometers between two points
6+
Calculate the great circle distance in kilometers between two points
77
on the earth (specified in decimal degrees)
8+
9+
Args:
10+
lat1 (float): Latitude of the first point in decimal degrees
11+
lon1 (float): Longitude of the first point in decimal degrees
12+
lat2 (float): Latitude of the second point in decimal degrees
13+
lon2 (float): Longitude of the second point in decimal degrees
14+
15+
Returns:
16+
float: Distance between the two points in kilometers
17+
18+
Examples:
19+
>>> round(haversine(40.7128, -74.0060, 51.5074, -0.1278), 2)
20+
5570.22
21+
>>> haversine(0, 0, 0, 0)
22+
0.0
23+
>>> round(haversine(0, 0, 90, 0), 2)
24+
10007.54
825
"""
926
# Convert decimal degrees to radians
1027
lat1, lon1, lat2, lon2 = map(math.radians, [lat1, lon1, lat2, lon2])

0 commit comments

Comments
 (0)