Modules in Python

Modules in Python:

We can use the PyCharm code editor for this example. If you do not know about it then follow this link- How to install PyCharm for Python and create a program in it.

(1) Modules are modular, often self-contained Python programs commonly utilized in other programs, hence the need to import them for access. Modules are used to separate code to make a program easier to work with as each module can be designed to do one thing well, rather than having to make a single program responsible for all logic.

(2) Example of Modules in Python:

In the below image, we have created two files in python i.e. gkscientist.py and module_example.py. We have created a program in gkscientist.py and called it in module_example.py and get the desired output.

python module example 1 file
python module example 2 file 1

We can also shorten the name of the module as shown below.

shorten module name in python

Another method to call the program gkscientist.py to module_example.py is shown below.

Call Particular Function

Call Particular Function of module in python

Call All Function* asterisk sign import all values.

Call All Function of module in python

Tutorial Python
Tutorial MySQL
Natural Language Processing (NLP)
Basic Components of Computer System
Characteristics of Computer
Applications of Computer
Python (programming language)– Wikipedia

Comments (No)

Leave a Reply