Python has a lot of inbuilt modules but if you want to categorize it then there are three main types of modules in Python:
- Built-in Modules: Python Standard Library (math module)
- External Modules: Installed using pip, Python’s package management tool.
- User-Defined Modules: Files containing functions, variables, etc defined by the developer in your Python program.
Complete list:- https://docs.python.org/3/py-modindex.html
Most used types of modules in Python
These Python packages every developer should know and learn:
- NumPy – Basic mathematical operations without any special Python packages.
- Pendulum
- Python Imaging Library. …
- MoviePy. …
- Requests. …
- Tkinter. …
- PyQt. …
- Pandas.
- Pywin32
- Pytest
Custome module example in Python
You can make your own modules and use them. it will help to easily understand code and increase code reusability.
Create: Save this code in a file named main.py
var = "Hello main file"
num = 9876543210
def greeting(name):
print("Hello, " + name)
Import and use: Just use the import statement
import main
main.greeting("John")
print(main.num)
Output:
![Types of modules in Python](https://i0.wp.com/tutorial.eyehunts.com/wp-content/uploads/2021/09/Types-of-modules-in-Python.jpg?resize=827%2C673&ssl=1)
How many types of modules are there in Python?
Answer: The Python standard library has almost 200 modules, although the exact number varies between distributions.
Do comment if you have any doubts or suggestions on this Python modules tutorial.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
Windows 10
Python 3.10.1
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.