Subjects

All subjects Django Java Python React Spring Boot JavaScript PHP
Sign Up Free
Python 10 questions

Modules, Packages & Virtual Environments

Organize Python projects. Learn import systems, module resolution, package architectures, pip installations, and virtualenv setups.

More Python
Interview questions 1–10 of 10
1

What is the difference between a module and a package in Python?

TermDefinitionModuleA single .py file containing Python code (functions, classes, variables)PackageA directory...

Read answer →
2

What is __init__.py used for in Python packages?

__init__.py marks a directory as a Python package and runs automatically when the package is first imported. I...

Read answer →
3

What is the difference between absolute imports and relative imports in Python?

TypeSyntaxBased onAbsolute importfrom myapp.utils import helperFull path from the project rootRelative importf...

Read answer →
4

What is a virtual environment and why should you use one?

A virtual environment is an isolated Python installation with its own set of packages, separate from the syste...

Read answer →
5

What is the difference between pip install and pip install -e (editable install)?

CommandBehaviorpip install packageCopies a snapshot of the package's code into site-packagespip install -e .Li...

Read answer →
6

How does Python find and import modules? What is sys.path?

When you import a module, Python searches through a list of directories stored in sys.path, in order, until it...

Read answer →
7

What is the difference between requirements.txt and pyproject.toml?

FilePurposeFormatrequirements.txtSimple list of dependencies (traditional pip approach)Plain text, one package...

Read answer →
8

What is the difference between import module and from module import name?

StyleAccess patternNamespaceimport modulemodule.nameKeeps names in the module's own namespacefrom module impor...

Read answer →
9

What is the __name__ == '__main__' idiom used for?

This idiom lets a Python file work both as a standalone script AND as an importable module, by checking whethe...

Read answer →
10

What is a namespace package, and how do circular imports happen?

A namespace package (PEP 420) is a package split across multiple directories without an __init__.py, useful fo...

Read answer →