Lesson 4 of 60 · python
Python Functions, Modules, and Packages
Duration: 20 minutes
Functions, Modules, and Packages
Modular code makes data pipelines reusable and testable.
Defining functions
def greet(name: str) -> str:
"""Return a friendly greeting."""
return f"Hello, {name}!"
Importing standard modules
import math
from collections import Counter
print(math.sqrt(16)) # 4.0
Installing third‑party packages
pip install numpy pandas
Creating your own package
my_project/
│
├── my_package/
│ ├── __init__.py
│ └── utils.py
└── setup.py
utils.py could contain helper functions used across notebooks.