1import numpy as np
2a = np.array((1,1,1))
3b = np.array((2,2,2))
4dist = np.linalg.norm(a-b)
5
1# Use numpy.linalg.norm:
2import numpy as np
3
4a = np.array([1.0, 3.5, -6.3])
5b = np.array([4.5, 1.6, 1.2])
6
7dist = np.linalg.norm(a-b)
1# I hope to be of help and to have understood the request
2from math import sqrt # import square root from the math module
3# the x and y coordinates are the points on the Cartesian plane
4pointA = (x, y) # first point
5pointB = (x, y) # second point
6distance = calc_distance(pointA, pointB) # here your beautiful result
7def calc_distance(p1, p2): # simple function, I hope you are more comfortable
8 return sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2) # Pythagorean theorem
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