how to find the euclidean distance in python code example
Example 1: euclidean distance python
from math import sqrt
pointA = (x, y)
pointB = (x, y)
distance = calc_distance(pointA, pointB)
def calc_distance(p1, p2):
return sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2)
Example 2: numpy euclidean distance
dist = numpy.linalg.norm(a-b)
Example 3: euclidian function in python
import math
x = (5, 6, 7)
y = (8, 9, 9)
distance = math.sqrt(sum([(a - b) ** 2 for a, b in zip(x, y)]))
print("Euclidean distance from x to y: ",distance)