> 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/shapes/2d/line.md).

# line()

Line - Draws a line segment with the given inputs

### Example

![](https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2FXQNbqxMt6GJMMqpYMUcI%2Fline.png?alt=media\&token=eb2cae76-077f-4e57-baa4-9139a510b7d6)

```python
line(100,100,300,300)
```

### Syntax

```python
line(x1, y1, x2, y2)
```

<table><thead><tr><th width="167">Input</th><th>Description</th></tr></thead><tbody><tr><td>x1</td><td>x co-ordinate of the first endpoint of the line</td></tr><tr><td>y1</td><td>y co-ordinate of the first endpoint of the line</td></tr><tr><td>x2</td><td>x co-ordinate of the second endpoint of the line</td></tr><tr><td>y2</td><td>y co-ordinate of the second endpoint of the line</td></tr></tbody></table>

<figure><img src="https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2FJx4XHzNAG5AtOG0NlmzI%2Fspaces_qbs7pgU3AVBY06Rl9M31_uploads_EZNsEiHZfCJGKsMfXu38_image.png?alt=media&amp;token=f9273a77-c655-4196-93c4-3973d589b57f" alt=""><figcaption></figcaption></figure>

### Description

**line()** draws a line on the canvas, using the inputs to determine the position of the 2 endpoints (the points on either end of the line segment.)

{% 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 %}
