Python math.dist() Method
Example
Find the Euclidean distance between two single-dimensional points:
# Import math Library
import math
# The first point of Euclidean
space
p = [3]
# The second point of Euclidean space
q =
[1]
## Calculate the distance between point p and q
print
(math.dist(p, q))
The result will be:
2.0
Definition and Usage
The math.dist() method calculates the euclidean distance between two points (p and q), where p and q are the coordinates of that point.
The points can be 1-dimensional or n-dimensional.
Note: Both points must have same dimensions.
Syntax
math.dist(p,q)
Parameter Values
| Parameter | Description |
|---|---|
| p | Required. First point of Euclidean space |
| q | Required. Second point of Euclidean space |
Technical Details
| Return Value: | A float value, representing the distance between two points |
|---|---|
| Python Version: | 3.8 |


