Creating and Using Python Modules

This post is very useful. As we can see many times we face different problems that need a solution of the ones before, or to use it as a step to solve a bigger problem. The point is that defining functions is not the only way to reuse code.

Python has the advantage of saving our previous files and use them as a module, like the one we import to use some math functions. So in order to use some previously defined functions we create a Python file and import it in another to make use of its content!

I will use two of our previous programs to help me prove this. In order to calculate the standard deviation we had to use the factorial of a number. So instead of going to our old factorial code we could have just imported it and made use of it!

CC BY 4.0 Creating and Using Python Modules by Manuel Lepe is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.