Dist Function In Python Math Module

Function Name:

dist

Function Signature:

dist()

Parameters:

p – Point one.

q – Point Two.

The two points should be of the same dimensions.

Overview:

  • The dist() function of Python math module finds the Euclidean distance between two points.
  • Euclidean distance between the two points is given by 

Euclidean Distance Formula

Example:

# Example Python program to find the Euclidean distance between two points

import math

 

# Define point1

point1 = (2, 2);

 

# Define point2

point2 = (4, 8);

 

# Find the Euclidean distance

euclidean_distance = math.dist(point1, point2);

 

# Print the Euclidean distance

print("The Euclidean distance between point1(%s) and point2(%s):"%(point1, point2));

print(euclidean_distance);

 

Output:

The Euclidean distance between point1((2, 2)) and point2((4, 8)):

6.324555320336759


Copyright 2023 © pythontic.com