6. Modules and packages Flashcards

1
Q

installing a package

A

pip install xxxx

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is a modules

A

module is just py.script

from mymodule import my_func

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is a package

A

package is a bunch of modules
package needs to put a “__init__.py” file inside the folder

from mypackage import mymodule

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

at the bottom of a .py script

A
if \_\_name\_\_ == "\_\_main\_\_":
    function 1()
    function 2()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

2 ways on importing built-in module

A
  1. import random
    *when you use, “random.randint”
    2a. from random import randint
    *when you use, just randint()
    2b from random import *
    no need random. anymore
How well did you know this?
1
Not at all
2
3
4
5
Perfectly