euclidean distance python 3 variables

Solutions on MaxInterview for euclidean distance python 3 variables by the best coders in the world

showing results for - "euclidean distance python 3 variables"
Reid
07 Mar 2017
1
2# Python code to find Euclidean distance 
3# using sum() and square() 
4  
5import numpy as np 
6  
7# intializing points in 
8# numpy arrays 
9point1 = np.array((1, 2, 3)) 
10point2 = np.array((1, 1, 1)) 
11  
12# finding sum of squares 
13sum_sq = np.sum(np.square(point1 - point2)) 
14  
15# Doing squareroot and 
16# printing Euclidean distance 
17print(np.sqrt(sum_sq)) 
18