Calculate the Euclidean distance using NumPy

 Using square() and sum() 


import numpy as np

point1 = np.array((5,2))

point2 = np.array((1,5))

sum_sq = np.sum(np.square(point1 - point2))

print(np.sqrt(sum_sq))


No comments: