Module
A file of Python code you can import and reuse in other programs.
A module is simply a .py file whose functions, classes, and variables you can reuse elsewhere with import. Python ships with a large standard library of ready-made modules — for math, dates, random numbers, files, and much more. After importing, reach inside with a dot (math.sqrt) or pull specific names out with from math import sqrt.
import math # a standard-library module
print(math.sqrt(16)) # use one of its functions
print(math.pi) # and one of its constants
from datetime import date
print(date(2025, 1, 1).year)
Output
4.0 3.141592653589793 2025
Where this shows up in real Python
Modules let you reuse code across files and tap the standard library — os, json, datetime, and many more.
Commonly used Module tools
import json— bring in a whole modulefrom pathlib import Path— import just one nameimport numpy as np— import under a shorter aliasdir(module)— list what a module offershelp(thing)— read its built-in documentation
Official documentation: Python Tutorial: Modules