Creating your own Modules in Phyton

--Originally published at Ed_Alita

Creating a Module

This is the 2nd part of my last post. In a new document of phyton we are goig to create a module or librarie. Therefore the first thing to do is to define a funtion and what does the funtion have to do.

The next exmaple is on how to get the fibonnacci serie.

This is a very simple example:

fibo

In this second case is the same only it put the result in a list:

Then we save it as Fibo.py

Using it

Now we go to cywin or your compiler.

  1. We got to the location of our programs.
  2. Next we put python3 and presss enter.
  3. Then we import the Fibo archive.fiboex1
  4. Then we put Fibo.fib(10) With this we are calling a funtion that is inside of  Fibo.

fiboex2fiboex3

The information mentionted in this archive is in the next link

https://docs.python.org/2/tutorial/modules.html