Interview Question

What are modules in Python?

A module is an importable unit with its own namespace.

💡 Concept ✅ Quick Revision 🐍 Python

Answer

A Python module is a file or other loadable unit containing Python definitions and statements. • Importing a module creates or retrieves its module object. • The module has its own global namespace. • The import system searches and loads modules according to configured finders and paths.

💡 Simple Example

import math print(math.sqrt(16))

Output

4.0

⚡ Quick Revision

A module is an importable unit with its own namespace.