---
title: "What is meant by module in python?"  
description: "What is meant by module in python?"  
author: "Amrita Bhattacharjee"  
published: 2023-03-28  
updated: 2023-04-18  
canonical: https://www.mindstick.com/forum/157633/what-is-meant-by-module-in-python  
category: "python"  
tags: ["python"]  
reading_time: 2 minutes  

---

# What is meant by module in python?

What is meant by [module](https://www.mindstick.com/blog/11796/prestashop-one-page-checkout-module-make-checkout-faster) in [python](https://www.mindstick.com/articles/75378/simple-yet-useful-tips-when-using-python)?Give suitable example.

## Replies

### Reply by Aryan Kumar

A module is a file in the Python programming language that contains definitions, commands, and functions. A module has the ability to import other modules and declare variables, functions, and classes. Before executing a programme, a Python interpreter looks for any module dependencies that are necessary. If a module is necessary, the import statement will be used to import it into the programme. A module can be either a third-party module that is installed separately or a built-in module that is part of the Python installation. The built-in Python modules os, sys, math, and random are some of the most popular ones. A module must first be imported using the import statement into the programme before it can be used.

### Reply by Krishnapriya Rajeev

A Python module is a file that contains *Python definitions* and *statements*. It can define functions, classes, and variables, and can also include executable code. Modules allow you to *locally organize* your Python code, as grouping related code into a module makes the code easier to understand and use.

Let us create a Python file for a simple module operation.py in which we define two functions addition() and subtraction():

```plaintext
# Module operation.py
def addition(a, b):
return (a+b)
def subtraction(a,b):
return (a-b)
```

We can now import this module and access its member functions into another Python source file as shown:

```plaintext
# Import module operation.py
import operation
# Access the function
print(operation.addition(2, 5))
# Output = 7
```

We can also import specific attributes from a module into the current Python file using the from...import statement:

```plaintext
from operation import subtraction
```

To import all the attributes, we use *:

```plaintext
from operation import *
```


---

Original Source: https://www.mindstick.com/forum/157633/what-is-meant-by-module-in-python

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
