Hello guys. How are you all? How to calculate euclidean distance in python. In this tutorial, we will discuss the different types of Euclidean dimensional spaces with formulas to calculate them. It is used to measure the length of a segment connecting the two points. We are going to learn about **How to calculate euclidean distance in python**. so without wasting time lets learn about of this.

## How to calculate euclidean distance in python

**calculate euclidean distance in python**to calculate euclidean distance in python just

**use****numpy.sqrt()**. By using numpy.sqrt() you can calculate euclidean distance in python. It is very easy to use. Lets learn about of this by given below example:Output :`import numpy as np arr1 = np.array((7,8,9)) arr2 = np.array((4, 5, 6)) temp = arr1-arr2 dist = np.sqrt(np.dot(temp.T, temp)) print(dist)`

**5.196152422706632****How to calculate euclidean distance in python**to calculate euclidean distance in python

**Use math.dist()**. By using math.dist() you can calculate euclidean distance in python. It is very easy to use. Lets learn about of this by given below example:Output :`from math import dist arr1 = (7,8,9) arr2 = (4, 5, 6) print(dist(arr1,arr2))`

**5.196152422706632****euclidean distance formula python**To calculate euclidean distance in python

**Use math.dist()**. By using math.dist() you can calculate euclidean distance in python. It is very easy to use. Lets learn about of this by given below example:Output :`from math import dist arr1 = (7,8,9) arr2 = (4, 5, 6) print(dist(arr1,arr2))`

**5.196152422706632**

## Method 1: Use numpy.sqrt()

By using numpy.sqrt() you can calculate euclidean distance. It is very easy to use. Lets learn about of this by given below example:

```
import numpy as np
arr1 = np.array((7,8,9))
arr2 = np.array((4, 5, 6))
temp = arr1-arr2
dist = np.sqrt(np.dot(temp.T, temp))
print(dist)
```

Output :

`5.196152422706632`

## Method 2: Use math.dist()

By using math.dist() you can calculate euclidean distance. It is very easy to use. Lets learn about of this by given below example:

```
from math import dist
arr1 = (7,8,9)
arr2 = (4, 5, 6)
print(dist(arr1,arr2))
```

Output :

`5.196152422706632`

## Method 3: Use numpy.sum()

By using nympy.sum() you can calculate euclidean distance. It is very easy to use. Lets learn about of this by given below example:

```
import numpy as np
arr1= np.array((7,8,9))
arr2= np.array((4, 5, 6))
dist = np.sqrt(np.sum(np.square(arr1-arr2)))
print(dist)
```

Output :

`5.196152422706632`

**Conclusion**

It’s all About this Tutorial. Hope all methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which method worked for you?

**Also, Read**