Start of main content## Recommended snippets

Calculates the average of two or more numbers.

- Use
`sum()`

to sum all of the`args`

provided, divide by`len()`

.

```
def average(*args):
return sum(args, 0.0) / len(args)
```

```
average(*[1, 2, 3]) # 2.0
average(1, 2, 3) # 2.0
```

### Weighted average

Python, Math

Returns the weighted average of two or more numbers.

### Mapped list average

Python, Math

Calculates the average of a list, after mapping each element to a value using the provided function.

### Geometric progression

Python, Math

Initializes a list containing the numbers in the specified range where

`start`

and`end`

are inclusive and the ratio between two terms is`step`

.