What is a Python module?

Questions & AnswersCategory: PythonWhat is a Python module?
Geek Boy Staff asked 2 years ago

What is a Python module?

a. A module is a file containing Python code (classes, functions variables, etc.). In the module, the name of the module (as a string) is available as the global variable name.
b. A module is a file containing Python code (classes, functions variables, etc.). The module name is the name of the file without the .py extension. In the module, the module name (as a string) is available as the global variable __name__
c. A module is another name for a function.
d. A module is a directory that contains Python scripts.

1 Answers
Lokesh Kumar Staff answered 2 years ago

b. A module is a file containing Python code (classes, functions variables, etc.). The module name is the name of the file without the .py extension. In the module, the module name (as a string) is available as the global variable __name__

 
Explanation

A module is a file containing Python definitions and statements. The file name is the module name with the suffix .py appended. Within a module, the module’s name (as a string) is available as the value of the global variable __name__.