Learn / Intermediate
Python Intermediate
Write Python like a professional: comprehensions, classes, modules, generators, decorators, typing and tests.
10 free lessons · about 2.2 hours · runnable code, exercises and quizzes
- 1ComprehensionsPython list, dict and set comprehensions and generator expressions: transform and filter data in one readable line, and know when a normal loop is better.10 min
- 2Lambda, map, filter and reducePython lambda functions, map(), filter() and functools.reduce(), plus sorted() with key, any(), all() and partial() — and when a comprehension is clearer.10 min
- 3Classes and objectsPython classes explained: __init__ and self, methods, __repr__, class attributes, inheritance with super(), properties and when a class is the right tool.14 min
- 4DataclassesPython dataclasses: less boilerplate with @dataclass, default values and default_factory, frozen and ordered dataclasses, asdict() and slots.9 min
- 5Modules, packages and environmentsPython modules and packages: import styles, writing your own module, __name__ == "__main__", packages with __init__.py, virtual environments, pip, uv and pyproject.toml.13 min
- 6Iterators and generatorsHow Python for loops really work: iterables and iterators, iter() and next(), generator functions with yield, lazy pipelines, and itertools for real tasks.12 min
- 7DecoratorsPython decorators step by step: functions as objects, closures, writing a decorator with functools.wraps, decorators with arguments, and real uses like timing, retries and caching.13 min
- 8Type hintsModern Python type hints: annotating variables and functions, list[int] and dict[str, float], optional values with X | None, type aliases, TypedDict, generics and checking with mypy.11 min
- 9Testing with pytestTest Python code with pytest: assert-based tests, running pytest, parametrized tests, testing exceptions, fixtures and how tests make AI-written code safe to use.12 min
- 10Project: build a game with pygameBuild a complete arcade game in Python with pygame-ce: a game window, the game loop, keyboard input, moving obstacles, collision detection, score and restart.25 min