Home >>Python math Module >Python math.dist() Method

Python math.dist() Method

Python math.dist() Method

Python math.dist() Method in python is used to returns and calculates the euclidean distance between two points (x and y), where x and y are the coordinates of that point and it accepts a number.

Syntax:
math.dist(p,q)

Parameter Values

Parameter Description
X It is Required for representing the First point of Euclidean space
Y It is required for representing the Second point of Euclidean space
Here is an example of Python math.dist() Method:

import math
x = [3]
y = [1]
print (math.dist(x, y))

Output:
2.0
Example 2:

import math 
x = [3, 9, 7, 2, 4, 5] 
y = [-5, -3, -9, 0, 6, 2] 
eDistance = math.dist(x, y) 
print(eDistance) 

Output:
21.93171219946131