# Module (Programming)

> A file of code. Other files can import it and use its parts.

**Field:** Software Development  
**Category:** Programming Concepts  
**Also known as:** Module, Code Module, Software Module

## Think of it like

It is like a kitchen drawer. Spoons go in one, and pans go in another.

## Definition

A module is one file of code that holds parts that go together, like functions and values. Other code can import it and use what is in it. Splitting a program into modules keeps each part small and easy to find. In Python, each .py file is a module. In JavaScript, a file that exports things is one too.

## Example

Jack's shop app has a module named prices.py. The cart code imports it to work out each total.

## Example code

```python
# prices.py
def add_tax(amount):
    return amount * 1.2

# cart.py
from prices import add_tax
print(add_tax(10))  # 12.0
```

One file holds the tax rule. The other file imports it.

## Why it matters

With modules, many people can work on one codebase at once. A bug is easier to find in a small file.

## Common mistake

Putting all the code in one huge file. It works at first, then nobody can find a thing.

## Three principles

- **Group related code.** One job or topic per module.
- **Import to use.** Other files pull in what they need.
- **Small parts.** Easier to read, test and change.

## Related terms

- [Codebase](https://learn.benibix.com/term/development/codebase)
- [Function](https://learn.benibix.com/term/development/function)
- [Software Library](https://learn.benibix.com/term/development/library)
- [Dependency](https://learn.benibix.com/term/development/dependency)
- [Python](https://learn.benibix.com/term/development/python)
- [Scope](https://learn.benibix.com/term/development/scope)

## Taught in

- [Code Blocks and Indentation](https://learn.benibix.com/learn/development-concepts/code-blocks-and-indentation): Programming Basics, 4/18

![Three boxes, one inside the next. The outer box is a codebase holding a project folder and many files. One file, cart.py, is a module. Inside it, the lines under an if sit pushed in by four spaces, and a bracket marks them as one code block.](https://learn.benibix.com/diagrams/dev7-code-parts.svg)

---

Source: https://learn.benibix.com/term/development/module
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
