Creating and using your own modules/libraries

--Originally published at My B10g

to create your own libraries you need some things first you need your file to end with the .py extension, then you need to write “def” followed by the name of your method and between “()” put the parameter which it will need if that´s the case, if not you just leave them empty.

def fib(n): # write Fibonacci series up to n
a, b = 0, 1
while b < n:
print(b, end=' ')
a, b = b, a+b
print()
code by Python Software Foundation

you can put as many methods you want inside the same .py file so you just need to import he file you need.

e00d06ddef93233a9c74fda0ff434b7744d210d787252f4d3d49796914e4f02d