# Function

*noun*

say it: **“FUNK-shun”** **/ˈfʌŋkʃən/**

A named block of code that does one job; you write it once and run it as often as you like by calling its name.

## What is a **function** in Python?

A **function** is a named block of code you write once with `def` and run whenever you need it, by calling its name
with parentheses. It can take values in and hand a value back.

```python
def add_tip(bill):
    return round(bill * 1.18, 2)

print(add_tip(40))   # 47.2
print(add_tip(25))   # 29.5
```

## In a sentence

- “The step counter has one **function** per job: one adds up the days, one finds the best day.”
- “She wrote a **function** that works out the tip, then called it for every table's bill.”

Level: Apprentice · [More Python terms at this level](https://www.ask-codey.com/glossary?category=python&level=2)

Updated: November 19, 2026

## In other subjects

- [Function in JavaScript](https://www.ask-codey.com/glossary/function)
- [Function in PowerShell](https://www.ask-codey.com/glossary/function-powershell)

Source: https://www.ask-codey.com/glossary/function-python
