Creating Modules

We use modules to break down large programs into small manageable and organized files. Furthermore, modules provide reusability of code.

We can define our most used functions in a module and import it, instead of copying their definitions into different programs.

Let us create a module. Type the following and save it as example.py.

And this is how we import it:

Hinterlasse einen Kommentar

Erstelle eine Website wie diese mit WordPress.com
Jetzt starten