A module is a file containing python definitions( functions and variables) and statements.The file name is the module name with the suffix  .py appended.

We need modules to reuse many functions,variables and statements.

To import a module in a program, we use the import keyword along with the name of the module. Ex: import operation. The first time a module is loaded into a running Python script, it is initialized by executing the code in the module once.

Let us write a small piece of code to multiply 2 numbers and also divide them.screenshot-112.png


This is a program called as It contains 2 functions multiply and divide which take in 2 parameters a and b and returns their product and quotient respectively.

Let us write another program.


This program is called . It imports the file called and prints the product of 2 numbers 4 and 6 using the multiply function of

The output is as follows.



Python has a standard list of built in modules. You can check them out here . Python modules

For example, we have math module. To use the math module we use import math statement. 

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Powered by

Up ↑

%d bloggers like this: