# bounce()

## Example

![](https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2Fup9jF7kvUsq0F7SWhKBg%2FNEWbounce%20\(1\).gif?alt=media\&token=7651f1db-2cce-4a48-8b31-2c7397bf3e03)

```python
def draw():
  ...  
  y = bounce(0,height,10)
  circle(200,y,20)
```

![](https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2FKYxAEEjCa0mpTO890Zt3%2Fbounce-2.gif?alt=media\&token=31c6b499-95ca-47a8-97a9-57c2bf2f0a2a)

```python
def draw():
  ...
  y = bounce(0,height,10)
  x = x + 1
  circle(x,y,20)
```

### Syntax

```python
bounce(edge1, edge2, speed)
```

<table><thead><tr><th width="162">Input</th><th>Description</th></tr></thead><tbody><tr><td>edge1</td><td>value for the start/first limit of the motion</td></tr><tr><td>edge2</td><td>value for the end/second limit of the motion</td></tr><tr><td>speed</td><td>the speed of motion</td></tr></tbody></table>

### Description

The `bounce` function provides a method for generating a value that changes or "varies" over time between two specific values: `edge1` and `edge2`.

`edge1` and `edge2` act as boundaries. `edge1` represents the smallest value that can be returned, and `edge2` represents the largest. The function will consistently generate a new value that is somewhere between these two boundaries.

The rate at which this value changes is determined by the `speed` parameter. A higher `speed` will cause the value to change more rapidly between `edge1` and `edge2`, while a lower `speed` will cause it to change more slowly.

This function is useful for cases where you need a value that continuously adjusts within a specific range, such as for animations, simulations, or other dynamic processes.

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