THE DEV BENCH
🐍

PCAP-31-03 — Reading Guide

Everything you need to LEARN PCAP is free. This maps each of the five official blueprint blocks to the canonical readings that cover it — the Python docs, the tutorial, and the relevant PEPs — with a short “what to know for the exam” note on each. Read the block, drill its deck, then write the code.

How to use this: work each block in order (or front-load OOP + Miscellaneous — together they're over half the exam). Read the free source, note the exam traps called out below, then lock it in with the matching deck and the coding track. Everything with a Read free link is the full, official text.

📦

Block 1Modules & Packages

12% of the examDeck: Block 1 (20 cards) · Exam: ~17 in the pool

How Python code is split across files and folders, and how import finds and runs it. Know the three import forms, what __name__ is, where Python searches (sys.path), what __init__.py and __all__ do, and the exam-favourite quirks of the math and random modules.

Modulesdocs.python.org · tutorial §6
Read free

The core reading: the three import styles (import m / from m import name / import m as alias), the module search path, and the classic `if __name__ == '__main__':` guard — a module's __name__ is '__main__' when run directly and the module's own name when imported. Executing an imported module runs its top-level code exactly once (later imports reuse the cached object).

Packagesdocs.python.org · tutorial §6.4
Read free

A package is a folder of modules marked by __init__.py. Learn dotted imports (import pkg.sub), and how __all__ controls exactly which names `from pkg import *` brings in. Single-underscore names are skipped by import *.

math — floor / ceil / trunc / sqrt / pidocs.python.org · library
Read free

Exam traps live here: floor rounds toward -infinity, ceil toward +infinity, trunc toward zero; sqrt ALWAYS returns a float (sqrt(9) → 3.0). Also pi, e, and factorial.

random — randint vs randrange, choice / sample / shuffle / seeddocs.python.org · library
Read free

The single most-tested distinction: randint(a, b) INCLUDES b, but randrange(a, b) EXCLUDES it (range semantics). choice() returns one element, sample() a subset, shuffle() reorders in place, seed() makes runs reproducible.

sys.path & the platform moduledocs.python.org · library
Read free

sys.path is the ordered list of directories import searches. The platform module is on the blueprint too: platform.system() returns 'Linux'/'Windows'/'Darwin', platform.machine()/processor() the hardware, platform.python_version() the interpreter version.

platform module reference
🧯

Block 2Exceptions

14% of the examDeck: Block 2 (22 cards) · Exam: ~20 in the pool

Handling errors the Python way: the full try/except/else/finally shape, raising and re-raising, custom exceptions, assertions, and — heavily tested — where each built-in error sits in the class tree.

Errors and Exceptionsdocs.python.org · tutorial §8
Read free

The main reading. Nail the clause semantics: else runs only when NO exception fired; finally ALWAYS runs (and a return in finally overrides one in try). Catch multiple types with a tuple `except (A, B):`; bind with `as e`; re-raise with a bare `raise`. Custom exceptions subclass Exception. `assert cond, msg` raises AssertionError when cond is falsy — and is disabled entirely under the -O flag.

Built-in Exceptions — the hierarchydocs.python.org · library
Read free

Memorise the tree at the bottom of this page. BaseException is the true root; Exception is what you normally subclass and catch. Know that LookupError is the base of IndexError and KeyError; ArithmeticError is the base of ZeroDivisionError; ValueError vs TypeError (wrong value vs wrong type); FileNotFoundError is an OSError. A base class in an except clause must come AFTER its subclasses or it makes them unreachable.

The raise statement & exception chainingdocs.python.org · reference
Read free

How raise works with and without an argument, and `raise X from Y` for chaining. Caught instances carry .args (a tuple of the constructor arguments) and str(e) for the message.

🔤

Block 3Strings

18% of the examDeck: Block 3 (26 cards) · Exam: ~25 in the pool

Strings are immutable sequences of Unicode characters. The exam drills indexing/slicing, code points (ord/chr), lexicographic comparison, and the essential methods — usually as 'what does this print?' snippets.

Text Sequence Type — str (and string methods)docs.python.org · library
Read free

The reference for every method the exam uses: split/join/strip/replace/find vs index (find returns -1, index raises)/count/startswith/upper/lower and the is* predicates. Remember strings are IMMUTABLE — every method returns a new string; s[0]='x' raises TypeError.

String methods (jump to the list)
Strings (indexing & slicing basics)docs.python.org · tutorial §3.1.2
Read free

The gentle introduction to negative indexing (s[-1] is the last char), slicing (start-inclusive, stop-exclusive), steps and reversal (s[::-1]), and why slicing never raises on out-of-range bounds while plain indexing does.

ord / chr and the Format Specificationdocs.python.org · library
Read free

ord('A') → 65 and chr(65) → 'A' are inverses; string comparison is by code point, so 'Z' (90) < 'a' (97). Skim the format() mini-language for {} placeholders and alignment/precision.

Format String Syntax
🧬

Block 4Object-Oriented Programming

34% of the exam — the biggest blockDeck: Block 4 (32 cards) · Exam: ~46 in the pool

A full third of the score. Classes and instances, instance vs class variables (and shadowing), inheritance and the MRO, super(), encapsulation and name mangling, introspection, and the special ('dunder') methods that make operators and built-ins work on your objects.

Classesdocs.python.org · tutorial §9
Read free

The single most important reading for the exam. self, __init__, the difference between class variables (shared) and instance variables (per-object) and how assigning through self SHADOWS a class variable, inheritance, super().__init__(), and name mangling (__x inside class C becomes _C__x). Also scopes — the setup for closures/nonlocal in Block 5.

Multiple inheritance & the MROdocs.python.org · glossary + tutorial §9.5.1
Read free

With class C(A, B), method lookup follows the Method Resolution Order — C, then bases left-to-right, then object — computed by C3 linearization. Read C.__mro__ to see it. This is a favourite 'which method runs?' question.

MRO — glossary definition
Special method names (dunder methods)docs.python.org · reference (data model)
Read free

How to make your objects behave like built-ins: __str__ (for print/str) vs __repr__ (debug/echo), __eq__ for ==, __add__ for +, __len__ for len(), __call__ to make an instance callable, __init__/__new__/__del__ lifecycle. Skim — you need recognition, not memorisation.

Built-in functions for introspectiondocs.python.org · library
Read free

type(), isinstance(obj, Class) (True for subclasses; pass a tuple to test several), issubclass(A, B) (class-to-class), hasattr/getattr(with a default)/setattr, dir(), vars() (an object's __dict__). Know isinstance vs `type(x) is Class` (exact type only).

🧩

Block 5Miscellaneous — comprehensions, lambdas, closures, generators & I/O

22% of the examDeck: Block 5 (32 cards) · Exam: ~30 in the pool

The 'functional & lazy Python' block: list/dict/set comprehensions, lambdas with map/filter/sorted, closures and nonlocal, generators and the iterator protocol, and file I/O with the with statement. Second biggest block after OOP.

Data Structures — comprehensionsdocs.python.org · tutorial §5
Read free

List, dict, and set comprehensions and nested/flattening forms. The key distinction the exam tests: a trailing `if` is a FILTER ([x for x in xs if cond]), while an `if/else` BEFORE the for is a per-element TRANSFORM.

Lambdas with map / filter / sorteddocs.python.org · tutorial §4.9.6 + library
Read free

A lambda is a single-EXPRESSION anonymous function. map/filter return lazy, single-pass iterators in Python 3 (wrap in list()). sorted(..., key=...) returns a NEW list; list.sort() mutates in place and returns None.

map / filter / sorted (built-ins)
Iterators & generatorsdocs.python.org · tutorial §9.8–9.11 + PEP 255
Read free

The iterator protocol is __iter__ + __next__ (raising StopIteration when done). A function with `yield` is a generator; (expr for x in xs) is a generator expression. All are LAZY and SINGLE-PASS — once exhausted they yield nothing more. PEP 255 is the original generators proposal.

PEP 255 — Simple Generators
Reading & writing files (with the with statement)docs.python.org · tutorial §7.2 + PEP 343
Read free

Open modes: 'r' read, 'w' TRUNCATES/creates, 'a' appends, 'x' fails if the file exists, '+' read/update, 'b' binary. read()/readline()/readlines() and iterating a file line-by-line. Always prefer `with open(...) as f:` — it closes the file even on an exception (PEP 343).

PEP 343 — The 'with' statement
Scopes, closures & nonlocaldocs.python.org · tutorial §9.2 + PEP 3104
Read free

The LEGB lookup rule, and how a closure (an inner function) captures variables from its enclosing scope. Use `nonlocal` to REBIND an enclosing variable, `global` for module scope. Watch the late-binding trap: closures capture the variable, not its value at creation.

PEP 3104 — Access to Names in Outer Scopes

Note: the docs are versioned to Python 3 and match the PCAP-31-03 objectives. Prices/versions of the linked courses shift over time — always confirm the current exam status and syllabus at pythoninstitute.org before you book. The current 31-03 (lifetime validity) is scheduled to retire August 31, 2026.

Take the practice exam Back to the PCAP path