0% found this document useful (0 votes)
2 views1 page

Python Modules Packages Assignment

A module is a single Python file with functions, classes, or variables, while a package is a directory of modules containing an __init__.py file. To create a module, write code in a .py file and import it in another file. The __init__.py file marks a directory as a package and can execute initialization code upon import.

Uploaded by

preetamsalunke0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Python Modules Packages Assignment

A module is a single Python file with functions, classes, or variables, while a package is a directory of modules containing an __init__.py file. To create a module, write code in a .py file and import it in another file. The __init__.py file marks a directory as a package and can execute initialization code upon import.

Uploaded by

preetamsalunke0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Python Functions Assignment

1. What is the difference between module and package?

A module is a single Python file that contains functions, classes, or variables. A package is a

collection of modules organized in a directory that contains an __init__.py file. Modules help in

organizing code, while packages help in organizing modules.

2. How do you create and use a module in python?

To create a module, write Python code in a .py file (e.g., mymodule.py). You can define functions,

classes, or variables inside it. To use it, import the module using 'import mymodule' or 'from

mymodule import function_name' in another Python file.

3. What is the significance of the __init__.py file in python?

The __init__.py file is used to mark a directory as a Python package. It allows the directory to be

imported as a package. It can also execute initialization code for the package when it is imported.

You might also like