Last Updated: Sunday 29th January 2017

In Python, modules are Python files containing Python functions to be implemented in your code. You’ll know a file is a module because of its .py extension. We can import modules easily using the import command, like this:

import mymodule

The example above will work when theres a file called from which functions can be imported.

Then to use any of the functions from the module, your code will have to look like this:

//import module
import mymodule
//run function

From there, you can use your functions and pass any parameters that you need to/can according to the functions as they’re defined in the original module files.

To Practice: Try this interactive course on the basics of Lists, Functions, Packages and NumPy in Python.