Python Quest

Learning map · Track 10 · intermediate

Modules, Libraries and the Python Ecosystem

Nobody writes every line of a real program from scratch. Python ships with a large standard library — modules for maths, randomness, statistics, dates and time zones, counting and grouping, file paths, JSON, CSV, regular expressions and exact decimal money — and hundreds of thousands of further packages are a single pip install away. This track teaches you to find, import and use that code confidently, and to organise your own programs the same way: as modules and packages that other files can import.

It is written for learners who already know functions, data structures, text, files and error handling. The first half works through the standard-library modules you will reach for every week, with seeded randomness and fixed dates so every result is reproducible. The second half moves to the ecosystem around your code: splitting a program into files, packages and the if __name__ == "__main__" guard, then PyPI, pip, semantic versioning, virtual environments, requirements files and pyproject.toml. Commands you would type in a terminal are shown as clearly labelled demonstrations — the browser cannot run pip — and you practise the ideas behind them with real code: comparing versions, parsing requirement lines and reading project metadata. The track ends by reading documentation well, judging third-party packages, and building a small utility package step by step.

By the end of this track you can

  • Import modules in all the common forms, explore them with dir() and help(), and explain what an import actually does
  • Use the standard library for maths, reproducible randomness, statistics, dates and time zones, counting, grouping and iteration
  • Split a program into your own modules and packages, and use the __name__ == "__main__" guard correctly
  • Explain what PyPI, pip and virtual environments are for, and read and write the commands to install, list and isolate packages
  • Pin and parse dependencies in requirements.txt and pyproject.toml, and compare versions using semantic versioning
  • Read documentation, docstrings and signatures, and judge whether a third-party package is safe and maintained enough to depend on

Lessons

  1. 1Importing modulesUse import, from-import and aliases, understand what an import does, and explore a module with dir() and help().30 min · 4 exFree
  2. 2math, random and statisticsCalculate with the math module, generate reproducible random values with seeds, and summarise data with statistics.40 min · 4 exMembers
  3. 3Dates and timesRepresent dates and times with datetime, do arithmetic with timedelta, format and parse text, and convert between time zones with zoneinfo.45 min · 4 exMembers
  4. 4The collections moduleCount with Counter, group with defaultdict, name record fields with namedtuple and keep a sliding window with deque.40 min · 4 exMembers
  5. 5itertools and functoolsCombine, group, pair up and accumulate data with itertools, and build functions from functions with functools.reduce and partial.45 min · 4 exMembers
  6. 6Writing your own modulesSplit a program into several .py files, import your own modules, and understand what module-level code does and when it runs.40 min · 4 exMembers
  7. 7Packages and the main guardGroup modules into packages with __init__.py, import from them with absolute and relative imports, and use if __name__ == "__main__" so a file works both as a script and as a module.45 min · 3 exMembers
  8. 8A tour of the standard libraryMeet the modules you will use most — pathlib, json, csv, re, textwrap, string, decimal, fractions and uuid — and learn how to choose the right one.50 min · 4 exMembers
  9. 9pip and PyPIUnderstand what PyPI and pip are, read the commands to install, inspect and remove packages, and work with version numbers and semantic versioning in code.45 min · 4 exMembers
  10. 10Virtual environmentsUnderstand why each project needs its own isolated set of packages, and how to create, activate, use and ignore a virtual environment on Windows, macOS and Linux.40 min · 3 exMembers
  11. 11Dependencies and requirementsRecord a project's dependencies in requirements.txt and pyproject.toml, read version specifiers, pin versions for reproducible installs, and parse both formats with code.50 min · 4 exMembers
  12. 12Reading documentation and choosing packagesRead documentation, help() output, docstrings and signatures confidently, judge whether a third-party package is safe to depend on, and build a small utility package in four milestones.75 min · 7 exMembers