Small, runnable practice exercises for new Python programmers — each with a built-in self-check and a worked solution.
These exercises mirror the learning track on pythonbeginner.help. Read a topic, then practice it here.
-
Make sure you have Python installed (3.8+).
-
Open an exercise in the
exercises/folder and complete theTODOs. -
Run it — each file checks your answer with
assertand prints ✅ when it passes:python exercises/01_variables.py
-
Stuck? Compare with the matching file in
solutions/. -
Run every exercise at once with the bundled runner:
python run_all.py # stop on first failure python run_all.py --keep # run them all, report each result
The runner also reports any unfinished exercise (one that still contains ... TODO placeholders) as SKIP so you can see at a glance what's left to do.
| # | Exercise | Topic | Tutorial |
|---|---|---|---|
| 01 | Variables & types | Variables, int / str |
Learn → |
| 02 | String methods | Strings, slicing | Learn → |
| 03 | Lists | Lists, indexing, sorted() |
Learn → |
| 04 | Loops | for and range |
Learn → |
| 05 | Functions | def, return values |
Learn → |
| 06 | Dictionaries | dict, .get(), keys |
Learn → |
| 07 | Conditionals | if / elif / else, ternary |
Learn → |
| 08 | Files | open, read, write |
Learn → |
| 09 | Errors & try/except | try, except ValueError |
Learn → |
| 10 | Classes | class, __init__, methods |
Learn → |
Every push and pull request runs all of the solutions/*.py files through GitHub Actions on Python 3.11, so the answers are always verified to work. See .github/workflows/exercises.yml.
for f in exercises/*.py; do echo "== $f =="; python "$f"; done…or just use the runner above.
- 📚 Tutorials: pythonbeginner.help
- 📋 Python Cheatsheet
- 🔧 Python Error Fixes — when an exercise throws an error you don't recognise.
- ⭐ Awesome Python for Beginners — the curated resource list.
Released under CC0 1.0 by pythonbeginner.help — copy, remix, and teach with these freely.