Home / Python Modules / How to Create a Module in Python In this example we will show how to create a module in Python. Source Code # to create a module just save the code you want in a file with the file extension .py def area(width, height): return width * height