Week 4 - modules Flashcards
1
Q
What is a module?
A
It is similar to a library.
And the library contains classes and functions.
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.
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.
4
Q
What is a local variable?
A
A variable created within a function. Therefore it can only be used in the function.
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.
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.