What are modules and packages in Python?
Question
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
It will take less than 1 minute to register for lifetime. Bonus Tip - We don't send OTP to your email id Make Sure to use your own email id for free books and giveaways
Answer ( 1 )
A module is a Python file containing Python statements and definitions. For example, a file evenodd.py is a module, and we call it ‘even-odd’. We put similar code together in one module. This helps us modularize our code, and make it much easier to deal with. And not only that, a module grants us reusability.
A package, in essence, is like a directory holding sub-packages and modules. While we can create our own packages, we can also use one from the Python Package Index (PyPI) to use for our projects.