## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

# Finding the closest point

To find the closest point, we need to first calculate the distance between the current location (my location) and all points. Then, we need to find the point that has the smallest distance from my location.

So, for each of the points, we must apply an equation that returns the distance to my location and stores these results in the same order as the points in the following table:

Point index

x

y

Distance to my location

0

35

44

?

1

20

92

?

2

11

77

?

The distance between two points is given by the following equation:

Translating this equation to Python, we have the following code:

`distance = math.sqrt((xb-xa)**2 ...`

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required