the full guide

Modules: using other people's code

import, the math, random, statistics and datetime modules, and what pip does.

15 min Beginner

What you need: The earlier pages of this course. Nothing to install.

import

Python comes with a lot already written. import brings it in, so you never have to write it yourself.

modules.py
import math
import statistics as stats
from datetime import date

print(math.sqrt(16))
print(math.pi)
print(stats.mean([70, 80, 90]))
print(stats.median([70, 80, 100]))
print(date(2026, 11, 1).strftime("%A, %d %B %Y"))

Output

4.0
3.141592653589793
80
80
Sunday, 01 November 2026
random_seed.py
import random

random.seed(42)       # The same "random" numbers on every run
print(random.randint(1, 6))
print(random.choice(["red", "green", "blue"]))

Output

6
red

pip and virtual environments

On your own computer, pip installs extra packages, and a virtual environment keeps each project's packages separate. You type these in a terminal, not in Python. On this site, nothing needs installing.

python -m venv myenv            # Make an environment
myenv\Scripts\activate           # Turn it on (Windows)
source myenv/bin/activate       # Turn it on (Mac, Linux)
pip install pandas              # Install a package

Finished reading?