# Defining Functions — Python Fundamentals: From Basics to Async

Source: https://www.skillbyai.com/en/python/py-functions-basics

> Define reusable functions with def, return values, default arguments and avoid mutable default pitfalls.

## def and return

`def` starts a function. `return` sends a value back; without it, the function returns `None`.

```python
def area(width, height):
    return width * height

print(area(4, 5))   # 20
```

## Default arguments

**Default arguments** make a parameter optional by giving it a fallback value.

```python
def greet(name, greeting="Hello"):
    return f"{greeting}, {name}!"

print(greet("Ada"))
print(greet("Ada", "Hi"))
```

## Mutable default pitfall

Never use a mutable object like `[]` or `{}` as a default argument — it's created **once** and shared across calls.
