Posts

Showing posts with the label Modules

Modules

Image
A python module can be defined as a python program file which contains a python code including python functions, class, or variables. In other words, we can say that our python code file saved with the extension (.py) is treated as the module. We may have a runnable code inside the python module. Modules in Python provides us the flexibility to organize the code in a logical way. To use the functionality of one module into another, we must have to import the specific module. Example In this example, we will create a module named as file.py which contains a function func that contains a code to print some message on the console. Let's create the module named as file.py. Here, we need to include this module into our main module to call the method displayMsg() defined in the module named file. LOADING THE MODULE IN OUR PYTHON CODE We need to load the module in our python code to use its functionality. Python provides two types of statements as defined below. The import statement The f...