***Welcome to ashrafedu.blogspot.com ***This website is maintained by ASHRAF***
***Use tabs for Content***

POSTS

    Storing Functions in Modules

    A module is simply a file that contains Python code. A large program can be made into smaller modules, and each module contains functions that perform related tasks. With this Large programs are easier to debug and maintain when they are divided into modules.

    This approach, which is called modularization, makes the program easier to understand, test, and maintain.

    Modules also make it easier to reuse the same code in more than one program. Import the module in each program that needs to call one of the module functions.

    import circle

    When the Python interpreter reads this statement it will look for the file circle.py in the same folder as the program that is trying to import it. If it finds the file, it will load it into memory. If it does not find the file, an error occurs. Once a module is imported you can call its functions.