What is a module in python?

787    Asked by SuhaniRodrigues in Data Science , Asked on Jan 19, 2020
Answered by Suhani Rodrigues

 To make programming easy to understand and readable for other users, the programmer combines similar kinds of codes in one group which known as a module. We can define variables, classes, and functions in the module and these modules become part of the package in python. Module files in python are .py extension files and to use these modules in python environment you can import them with their package name reference.

For example, if there is a package name “DateTime” which has a module name “date”, to import this in python we write like this

From Packagename import moduleName

from DateTime import date



Your Answer

Interviews

Parent Categories