Standard Libraries
The Python Standard Library is a vast collection of modules that ships with every Python installation, ready to use immediately without installing anything extra. It's often described as Python's "batteries included" philosophy.
What the Standard Library Offers
The standard library covers an enormous range of everyday programming needs, including mathematical operations, working with dates and times, file and directory handling, random number generation, and much more - all without needing a single external package.
import math
import random
import datetime
print(math.sqrt(16)) # 4.0
print(random.randint(1, 10)) # a random number between 1 and 10
print(datetime.date.today()) # today's date
Why It Matters
- Saves time by providing pre-built, well-tested solutions for common tasks
- No installation required - available the moment Python is installed
- Maintained directly by the Python core team, ensuring long-term reliability
- Forms a strong foundation before reaching for third-party packages
A good rule of thumb: before installing a third-party package for a task, check whether the Python Standard Library already offers a built-in solution - it often does.
Coming Up Next
Next, you'll learn how packages and the import statement let you organize and reuse code, both from the standard library and from your own projects.