Euclidean distance formula is a very popular formula in mathematics. This is used to calculate the distance between two points in a two dimensional plane.
There are n points in a two dimensional plane. The requirement is to find the nearest point/s to a point P in the two dimensional plane.
- Get the value to n
- Get the values of all the n points (x,y)
- Get the value of point P
- Find the distance of each of the points to the point P.
- Find the point/s which has the shortest distance to point P and print those points.
The Euclidean formula
distance2 = (x2 – x1)2 + (y2 – y1)2
distance = square root of the above value.
The python program is given below.