Python TutorialLesson 26Free preview
Python Modules
This lesson is part of Python · All levels
Summary
A module is a Python file that contains a function, variable, or class that can be imported into another program so that the code does not need to be rewritten. We can use import modules, import... as for alias, or from import modules name. In addition, standard libraries such as math, random, and os are available directly without additional installation.
Key points
- Each file can be considered a module. (.py)
- The import module allows us to use the contents through the point.
- From the name import module import only certain parts.
- If __name__ == "__main__" separates the main code from the imported code.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.