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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learnpython.strivemath.com/p5-python-web/reference/controlling-the-environment/setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
