# Lambda Functions — Python

Source: https://www.geekswithgeeks.com/en/python/py-lambda

> Small, anonymous, one-expression functions.

## One-line functions

A `lambda` is a nameless function limited to a single expression — handy as a short-lived argument.

```python
square = lambda n: n * n
print(square(5))   # 25

people = [("Ada", 36), ("Bo", 24)]
people.sort(key=lambda p: p[1])
print(people)
```

## When to use lambda

Use `lambda` for throwaway callbacks (`sort`, `filter`, `map`); for anything with logic or a name worth reusing, write a normal `def`.
