Types of modules in Python | Basics

  • by

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 are containd functions, vraibles, etc defined by develper 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:

  1. NumPy – Basic mathematical operations without any special Python packages.
  2. Pendulum
  3. Python Imaging Library. …
  4. MoviePy. …
  5. Requests. …
  6. Tkinter. …
  7. PyQt. …
  8. Pandas.
  9. Pywin32
  10. Pytest

Custome module example in Python

You can make your own modules and use them. it will help to easily understand code and increasing code resuablity.

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



Types of modules in Python

How many types of modules are there in Python?

Answer: The Python standard library has almost over 200 modules, although the exact number varies between distributions.

Do comment if you have any doubts and suggestions on this Python modules tutorial.

Note: IDE: PyCharm 2021.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.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.