A huge part of Python's practical usefulness comes from code you don't have to write yourself — the standard library ships with Python itself, and pip installs anything else from the wider Python community.
You already used this with the math module. import makes a whole module available; from ... import ... pulls out just what you need:
import math
print(math.sqrt(64))
from math import sqrt
print(sqrt(64)) # same result, no math. prefix neededThe standard library is large and covers a lot of everyday needs — random (random numbers), datetime (dates, covered in its own lesson soon), json (reading/writing JSON), os (interacting with the operating system), among many others. The full standard library reference is on python.org.
Anything not in the standard library — a web framework, a data analysis library, an HTTP client — is installed with pip, Python's package manager, roughly equivalent to what npm is for JavaScript:
pip install requestsimport requests
response = requests.get("https://api.example.com/data")
print(response.status_code)Any .py file can be imported by another — this is Python's equivalent of PHP's require_once for splitting code across files:
# helpers.py
def greet(name):
return f"Hello, {name}!"# main.py
from helpers import greet
print(greet("Priya"))Virtual environments come later
Real Python projects almost always use a virtual environment to keep each project's installed packages separate from every other project's — covered properly in the "Where to Go Next" lesson at the end of this section, since it's more of a workflow habit than a language feature.