Nexus Learn

Log in · Create free account

Module 3: Functions and modules · 9 min

Modules, packages and pip

A module is a Python file you can import. Python comes with many (math, random, json, csv, datetime). Other people's packages are installed with pip.

import math
import random

print(math.sqrt(16))        # 4.0
print(random.randint(1, 6)) # a dice roll
pip install pandas matplotlib requests

Use a virtual environment (python -m venv venv) for each project, so that the packages of one project do not break another.

(free account needed to save progress)

← Writing functions  |  Working with JSON →