input: Write a python function to calculate the distance between two geographical locations given their latitude and longitude.
  assert abs(distance_between_locations(48.8606, 2.33619, 48.8644, 2.32883) - 0.486) < 0.001
  assert abs(distance_between_locations(34.0522, -118.2437, 36.7783, -119.4179) - 347.62) < 0.01
  assert abs(distance_between_locations(40.7128, -74.0060, 34.0522, -118.2437) - 3936.59) < 0.01
output: def distance_between_locations(lat1, lon1, lat2, lon2):
      from math import radians, sin, cos, sqrt, atan2
      
      # Convert latitude and longitude from degrees to radians
      lat1, lon1, lat2, lon2 = map(radians, [lat1, lon1, lat2, lon2])
      
      # Haversine formula
      dlat = lat2 - lat1
      dlon = lon2 - lon1
      a = sin(dlat / 2)**2 + cos(lat1) * cos(lat2) * sin(dlon / 2)**2
      c = 2 * atan2(sqrt(a), sqrt(1 - a))
      
      # Radius of Earth in kilometers
      r = 6371.0
      
      # Calculate the distance
      distance = r * c
      
      # Convert distance from kilometers to miles
      distance_miles = distance * 0.621371
      
      return distance_miles