Module
• A module can contain prede ned variable , functions , classes and we use
this things in di erent programs with the help of import
• Modules are nothing but python les . Normal programs can be modules
too
•
•
• Lets save this program as ModuleOne
•
• And this program as MyProgram
• In program ModuleOne we are de ning the function and in program
Myprogram we are calling the function ( add , sub )
• What happens if we write print function in ModuleOne program??
ff
fi
fi
fi
• it will print that function in MyProgram output
• If we want to execute only [Link] but not [Link](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
•