> 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/controlling-the-environment/setup.md).

# setup()

### Example

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

```python
def setup():
 background("grey")

def draw():
  fill(255,79,132)
  circle(mouseX,mouseY,100)
```

### Syntax

`setup()`

### Description

The setup() function is called only **once at the beginning** of the program. Its purpose is to set up the **initial environment** of the program, such as canvas size, background color, to load media such as images and fonts as the program starts and any other initial values that the program needs.&#x20;

The `setup()` function takes no arguments, and must be defined in the program before the `draw()` function.

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