17.1 Module.pdf
(
451 KB
)
Pobierz
Module
•
A module can contain predefined variable , functions , classes and we use
this things in different programs with the help of import
•
Modules are nothing but python files . Normal programs can be modules
too
•
•
•
Lets save this program as ModuleOne
•
•
And this program as MyProgram
•
In program ModuleOne we are defining the function and in program
Myprogram we are calling the function ( add , sub )
•
What happens if we write print function in ModuleOne program??
•
it will print that function in MyProgram output
•
If we want to execute only MyProgram.py but not ModuleOne.py(add and
subtract ) print function
•
For this we can ass print
(__name__)
•
It means the printing should be done only if its in main . If it is importing
then don’t execute the print function
•
We can also write
•
Plik z chomika:
kendzior21
Inne pliki z tego folderu:
1. Section Introduction.mp4
(25995 KB)
2. What are Functions.mp4
(29622 KB)
28. Challenge Flattening Nested List.mp4
(37117 KB)
26. Challenge Minimum Variable Number.mp4
(26891 KB)
10.1 Iterators&Generators.pdf
(1043 KB)
Inne foldery tego chomika:
01. Introduction to Python
02. Python Installation and Setup
03. Python Datatypes
04. Operators and Expression
05. Conditional Statements
Zgłoś jeśli
naruszono regulamin