Intermediate level · Module 3 of 6 · 14 guided hours
Modules, Packages and Virtual Environments
Structure larger programs across several files and manage third-party packages reproducibly.
Learning objectives
- Import from the standard library and your own modules
- Create and use a virtual environment
- Record dependencies in requirements.txt
Topics
- import statements
- useful standard library modules
- own modules and packages
- pip and venv
- requirements.txt
Lessons
-
Lesson 1 Using the Standard Library
Solve everyday problems with modules that ship with Python, without installing anything.
import / from-importdatetimestatisticsofficial documentation
-
Lesson 2 Splitting Code into Your Own Modules
Move functions into separate files and import them, creating a clean project layout.
modulepackage__init__.pyproject layout
-
Lesson 3 Packages with pip and Virtual Environments
Install third-party packages safely in an isolated environment and record them for others.
PyPIpip installvenvrequirements.txt
Practical activity
Restructure a single-file program into a packaged project with a venv and requirements.txt that runs on a second computer without changes.
Expected outcomes
- Reproducible, well-organised Python projects
- Safe use of third-party packages
Assessment
Peer swap: another learner sets up and runs the project from the README alone; instructor checks the result.
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.