(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.
We can also shorten the name of the module as shown below.
Another method to call the program gkscientist.py to module_example.py is shown below.
Call Particular Function
Call All Function– * asterisk sign import all values.
Comments (No)