Firstly we have to know about What is a Module?
Modules means the small parts of a library that separated into individual components.
and also they additionally holding separate units within themselves to use in an efficient way.
An added useful feature of having modules their contents can be reused under other programs,
without rewriting or recreate them.
For example, in case someone created a module like ‘Play game’ to play different game formats,
appearing from different sources, eg, console, game player, Playstation.
Now, while we creating a different program, if someone wants to combine extra features in it,
he no needs to re-write the code for it,
preferably he can use functionality from the play game module.
Structure of a Python Module
A Python module will contain enormously functions more than ordinary functions.
A Python module de a normal Python file (.py file) comprising one or more of the following objects related to a specific works.
the Triple quoted comments which useful for documentation ideas. For documentation, the docstrings should be the first string to stored inside a module or function body/class
variables and constants
the variables and constants are those will gives labels for data.
classes means nothing but a templates or blueprint which used to create the objects of a particular kind
objects are the instances of classes. to be more specific ,objects are representation of some real or abstract substance
Statements comprise the instructions given to the code for execution
we have seen already what are functions, it is a collection of code with a unique name by which we can access it anywhere and we can reuse them for as many times as we want for our code.
In conclusion , we can say that case the module ‘ABCD’ implies it is file name will looks like ABCD.py.
A Python module is a file (.py file) comprising variables class descriptions statements and functions related to a specific work.
Python becomes packed with some predefined modules that
we can use and we can even create our own modules.
The Python modules comes with preloaded with Python called standard library modules.
we have worked with one standard library module math earlier and now we shall also learn to interact with another standard library
module : random module.
Generally A module comprises independent set of code and data
like variables, definitions, statements and functions.
modules can also re-used in other programs.
modules can depend on other modules.