+ 1
Modules are pre available with python library or we need to declare and define ? how we can define modules?
1 Réponse
0
In my own understanding, A module is just an already made script which could be imported for use in another script. There are 3 types of modules:
1. Standard modules which come bundled with Python
2. Third party modules made by others
3. I call this one Personal Module, made by yourself(the coder)
All the types of modules can be added to a script for use by using the command
" import module name" or "from module name import specific part of module"
The first imports all parts of the script and the latter imports specific part of the script
Example: 1. import math - this imports all contents of math script
2. from math import pi - this import only pi from math module
To create personal module simply create your own program code e.g a calculator or
times table and save. Eg. calculator. py
When you need to use the same piece of code in another script you simply import the code from the calculator.py by "import calculator.py"
I guess I tried......Happy Coding!