> For the complete documentation index, see [llms.txt](https://learnpython.strivemath.com/p5-python-web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learnpython.strivemath.com/p5-python-web/reference/math/dist.md).

# dist()

## Example

<figure><img src="/files/4tpByEHWFTVXG1OU9iZ1" alt=""><figcaption></figcaption></figure>

### Syntax

#### In two dimensions

```
dist(x1, y1, x2, y2)
```

<table><thead><tr><th width="94">Input</th><th>Description</th></tr></thead><tbody><tr><td>x1</td><td>the x-coordinate of the first point</td></tr><tr><td>y1</td><td>the y-coordinate of the first point</td></tr><tr><td>x2</td><td>the x-coordinate of the second point</td></tr><tr><td>y2</td><td>the y-coordinate of the second point</td></tr></tbody></table>

#### In three dimensions

```
dist(x1, y1, x2, y2, z1, z2)
```

<table><thead><tr><th width="110">Input</th><th>Description</th></tr></thead><tbody><tr><td>z1</td><td>the z-coordinate of the first point</td></tr><tr><td>z2</td><td>the z-coordinate of the second point</td></tr></tbody></table>

```python
    text(round(dist(x1, y1, x2, y2)), 50, 50)
```

```python
  sphere(dist(0, 0, 0, x, y, z))
  
  x+=3*noise(2*frameCount)*random([-1, 1])
  y+=4*noise(frameCount)*random([im-1, 1])
  z+=noise(0.5*frameCount)*random([-1, 1])
```

<figure><img src="/files/uUNEzYHJkQDObWIapnuL" alt=""><figcaption></figcaption></figure>

### Description

Calculates the distance between two points, in either two or three dimensions. This uses the Euclidean distance, usually called the Pythagorean distance

{% hint style="info" %}
Find these documents helpful? Let the people who made them help your child learn to code at [**Strivemath**](https://www.strivemath.com/)<mark style="color:blue;">**!**</mark>

We'd love to hear your Feedback/Comments [here](https://docs.google.com/forms/d/e/1FAIpQLSeqorBAGTya-YBRI-VFjJxtgQtCz3ucGDI96K96sNyuaGuvdw/viewform?usp=sf_link).
{% endhint %}
