Lecture 8 Flashcards

Modules

1
Q

what is a module and what is its advantage?

A

A module is just a Python file.
Keep Python files small
Reuse code across multiple files by importing

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

what is a built in module?

A
  • comes with python by default, we do not need to download them using a package installer.

-We still have to manually import them to use them.

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

how do you rename a module? (incl. syntax)

A
  • We can give the alias to the module name or give it another name which we can refer it by using an as keyword
  • Once renamed, we can’t access the name of the module with old name

syntax:

import modulename as alias

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

how do you import parts of a module?

A

from keywrord

from modulename import methods (separated by commas)

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

how do you import an entire module using from keyword?

A

from modulename import *

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

what is an external module?

A

External modules are downloaded from the internet
You can download external modules using pip
pip - Package management system for Python

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

how do you use the help keyword?

A

to get documentation for a module

ex: import termcolor
print(help(termcolor))

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