Week 4 - modules Flashcards

1
Q

What is a module?

A

It is similar to a library.

And the library contains classes and functions.

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

How do you use a module?

A
You import the module.
To create a module all you need to do is save a file with an extension .py
Module are always written in the lower case.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you use a function in a module?

A
You call it by  module_name.function_name.
The dot notation must separate the module name and function name.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a local variable?

A

A variable created within a function. Therefore it can only be used in the function.

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

What is a global variable?

A

A variable within the main body of the program. It can be used inside or outside the function.

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

What does the keyword “global” do?

A

It makes any variable a global variable, which means even if it is created with the function it can be used anywhere in the program.

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