DEV Community

Dr. Azad Rasul
Dr. Azad Rasul

Posted on

9- What are modules in Python?

In the modules, we can use a set of functions without being required to redefine them. Then, from a group of related modules, we can create a package. Create a simple module:

def hi(name):
    print("Hello, " + name)
Enter fullscreen mode Exit fullscreen mode

Save it as "module1" in your directory.

Use the module:

import module1
module1.hi("Ali")
# Hello, Ali
Enter fullscreen mode Exit fullscreen mode

Built-in module

We can import various built-in modules in Python.

import platform
print(platform.system())
# Windows
Enter fullscreen mode Exit fullscreen mode

Import module from a package:

import matplotlib.pyplot as plt
Enter fullscreen mode Exit fullscreen mode

If you like the content, please SUBSCRIBE to my channel for future content.

To get full video tutorial and certificate, please, enroll in the course through this link: https://www.udemy.com/course/python-for-researchers/?referralCode=886CCF5C552567F1C4E7

Top comments (0)