Trending technologies

#AWS #Azure #Blockchain #IOT #machine learning #Virtual Reality #Analytics #Business Intelligence

Tutorials

Blogs

Module is a file consisting of Python code (Pre define Variable and functions) that you want to include in your application. It is similar to the code library.

Creating Module

Just save your code in .py extension.

Example Save the below code as sayHello.py


def callFun():
print("Hello, I am calling from module")

Look into below videos for easy understanding

Modules Explained

Modules in Python

Understanding Module

Using the Module

We can use the python module using the import keyword

Import sayHello;

sayHello.callFun();

Output

Hello, I am calling from module

Note: you can use dir() function to list all the Variable and function in module.

Alias a module: you can create alias name of module using as keyword.

Example


Import sayHello as sh;

sh.callFun();

Output

Hello, I am calling from module

Spread the Knowledge
error: Content is protected !!