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 ...

Start Free Trial

No credit card required