Modules and packages
A module is a Python file containing ready-to-use functions. Python ships with many: math for maths, random for randomness, datetime for dates… You load them with import.
import math gives access to math.sqrt(), and from math import sqrt lets you write sqrt() directly. A package is a folder that groups several modules. External packages are installed with pip, like pip install requests. To keep each project's packages separate, you create a virtual environment with python -m venv .venv.
import math import random from datetime import date print(math.sqrt(16)) print(math.pi) print(random.randint(1, 6)) print(date(2026, 1, 1).year)