Python 3.4 - Modules and Standard Library
Module are inventions that others or you make to reuse. They do things for you, like math! And they are free!
One module can do many things. Like the math module. You can find out what the module can do by looking up it directory:
dir(math) in Idle will give you a list.
Here is an index of all of the modules: https://docs.python.org/3/py-modindex.html
For example, the module.py has this function:
Importing the module:
Which will call upon the module.py file (make sure it's in the same directory) and use the function.
The result:
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
https://www.youtube.com/watch?v=iM3kh-fDg5o
One module can do many things. Like the math module. You can find out what the module can do by looking up it directory:
dir(math) in Idle will give you a list.
Here is an index of all of the modules: https://docs.python.org/3/py-modindex.html
For example, the module.py has this function:
def fib(n): a, b = 0, 1 while b < n: print(b) a, b = b, a+b
Importing the module:
import module module.fib(1000)
Which will call upon the module.py file (make sure it's in the same directory) and use the function.
The result:
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
https://www.youtube.com/watch?v=iM3kh-fDg5o
Comments