Python × CUB

We’ll keep this page up to date with lecture slides, additional materials, and links to every task and homework. Check back anytime for the latest course information.

Jump to current week ↓
Sep 5–11
Lecture
Intro — what is this course about?
Incredible Python — why Python?
How to run a program — a dozen ways to run a Python program
Python Gym — go to gym.andgein.ru to learn Python syntax and practice
Memory Model — how variables are stored and arguments are passed
Classes — object-oriented programming and standard types
I/O — file systems, working with files, context management, and networking

Additional materials

Transforming Code into Beautiful, Idiomatic Python
Although this is an older talk and some examples use Python 2 syntax, it is still a great talk about Pythonic ways to write code. I recommend returning to it throughout the course.
All Singing All Dancing Python Bytecode by L. Hastings
Clean Code Game
Seminar

Before the seminar

If you are new to Python, start with JetBrains' Introduction to Python course. You can complete it directly in PyCharm.

Everyone should work through a few chapters in the Python Gym. Take your time—more chapters will be added over the next few weeks.

Basic Python

Simple types: int, float, string, bool
Collections: list, tuple, dict, set
Time complexity of collections Advanced
import collections Advanced
Functions
Nested functions, scoping Advanced
IDE and debugging, Jupyter
Shallow vs deep copy
Sep 12–18
Seminar
How to approach a homework assignment
I/O
Working with files: modes, encodings, and context managers
Reading files line by line, the file cursor, and seek()
JSON and CSV: loading, saving, and robust parsing
Modules
Modules and import styles: import and from … import
The import path, module changes, and circular imports
Working with HTTP
Client-server requests, responses, and HTTP APIs
Fetching JSON with requests: query parameters, timeouts, and status checks
Request structure: methods, paths, headers, and bodies
Homework

Homework 1

Deadline: Sep 28, 08:00 CET
Following tasks are available in the LMS:
  1. Free time windows
  2. Equipment search
  3. JSON HTTP
  4. Non-empty lines
  5. JSON user filtering
  6. Availability catalogue
  7. Cheapest bundle
Grading is automatic once you push your solution to GitHub.
LLM policy: you may use LLMs only to ask questions; they must not produce any code. Write the entire submitted code by hand.
Talks

Topics announcement

We’re going to hold a small conference, where some of you will give talks! We’re looking for around five people who would like to prepare a presentation. Giving a talk at the conference earns bonus points.
Talk topics are now available in the topic spreadsheet. Choose a topic, then prepare a plan and send it to Andrey by the end of September. Prepare the text and all supporting materials except the slides by the end of October.
Your presentation should be almost ready by Nov 13, ahead of the conference, which will take place during seminars in the week of Nov 21–27.
Sep 19–25
Seminar
Environment and configuration
Environment variables and .env files
Configuration files: YAML, JSON, and INI
Paths and filesystem
Working with paths, files, and directories using pathlib
Traversing directories and moving files
Command-line programs
Arguments, standard input and output, and exit codes
Parsing arguments with argparse
Exceptions
Exception hierarchy, handling, and chaining
try, except, else, and finally
Context managers
Resource cleanup with with and custom context managers
Lab

Lab I — “Optimisation task”

Two tasks will be published around Sep 25, and you’ll have three weeks to choose one and develop a solution. A login link will be sent to the email address you specified in the LMS. Your goal is to write a program that beats a specified threshold by producing output at least as good as the reference solution. The task will be evaluated on several tests, most of which will be hidden. You may use LLMs and agents while working on the lab, but you must fully understand your solution and be able to answer any questions about the idea and the code.
Defend your solution during the seminar in the week of Oct 10–16.
Sep 26–Oct 2
Seminar
Decorators
Functions as objects, higher-order functions, and closures
Defining decorators and using the @ syntax
Reusable wrappers: *args, **kwargs, and functools.wraps
Decorators with parameters
Stacking decorators
Standard decorators: functools.lru_cache, functools.cache, @staticmethod, @classmethod, and functools.singledispatch
Deadline
Homework

Deadline for Homework 1

Please submit your homework by 08:00 CET on Sep 28.
Deadline
Talks

Call for Papers deadline

Choose a topic, prepare a brief plan for your talk, and send it to Andrey by the end of September.
Oct 3–9
Seminar
Regular expressions
Anchors, alternation, character classes, and escaping
Quantifiers and greedy vs lazy matching
Searching and validating text with re.search(), re.match(), and re.fullmatch()
Finding all matches with re.findall() and re.finditer()
Capturing, non-capturing, and named groups
Backreferences and text substitution with re.sub()
Regex flags: case sensitivity, Unicode and ASCII, multiline, dot-all, and verbose mode
Lookahead and lookbehind assertions
Backtracking, performance, and reusable patterns with re.compile()
Regular languages, finite-state machines, and regex limitations
Homework

Homework 2

Deadline: Oct 19, 08:00 CET
Following tasks are available in the LMS:
  1. Parse a log file
  2. Fill in a template
  3. Retry with a decorator
  4. Process a batch and report all failures
  5. Always clean up
  6. Limit function calls
  7. Validate function arguments
Grading is automatic once you push your solution to GitHub.
LLM policy: you may use LLMs only to ask questions; they must not produce any code. Write the entire submitted code by hand.
Oct 10–16
Deadline
Lab
Seminar
Defence of Lab I — “Optimisation task”
Submit the code for your chosen Lab I task and defend your solution during your assigned slot. You must be able to answer any questions about the idea behind your solution and the code. Your defence will directly affect your Lab I score.
Advance booking will be available, so you can choose a convenient slot. There will be no regular seminar that week.
Oct 17–23
Seminar
Classes and OOP
Constructors, instance vs. class attributes, methods
Magic methods
@dataclass
Inheritance, super(), and method overriding
Multiple inheritance Advanced
Polymorphism Advanced
Deadline
Homework

Deadline for Homework 2

Please submit your homework by 08:00 CET on Oct 19.
Oct 24–30
Lecture
Functional programming — how to write functions that operate on other functions
Concurrency and asynchronous programming — how to process thousands of requests simultaneously
OOP — classes, methods, inheritance, and more
Testing — how to test your code properly: libraries and approaches
Seminar
Async programming
Homework

Homework 3

Deadline: Nov 9, 08:00 CET
Tasks will be published on Oct 24.
Lab

Lab II — “Open-source contribution”

For this lab, you’ll work in pairs on a feature for an open-source project. We’ll provide a list of projects to choose from, along with some suggested ideas, but your own ideas are very welcome. Your goal is to understand how the project works and integrate a new feature appropriately.
You may use LLMs and agents while working on the lab, but you must fully understand the approaches you chose, the feature you implemented, and the code you wrote, and be able to answer any questions about them.
Defend your solution during the seminar in the week of Nov 14–20.
Deadline
Talks

Text and materials are ready

Finish the text and all supporting materials other than the slides by the end of October.
Oct 31–Nov 6
Contest

Team Competition

We’re still finalising the format. If the competition goes ahead, it will take place on a Saturday. The exact date is not yet confirmed; we’re currently considering Oct 31. The competition will be for teams of three. Participation is entirely optional, and you can earn bonus points for taking part and for strong results.
Seminar
Scientific Python — NumPy, SciPy, pandas
Testing — libraries and approaches
Nov 7–13
Seminar
FastAPI and building HTTP APIs
Building HTTP applications
Working with databases Advanced
Deadline
Homework

Deadline for Homework 3

Please submit your homework by 08:00 CET on Nov 9.
Deadline
Talks

Presentation draft is ready

Have an almost complete draft of your presentation ready by Nov 13.
Nov 14–20
Lecture
Details will be added later
Deadline
Lab
Seminar
Defence of Lab II — “Open-source contribution”
Submit the code for your feature and defend your contribution during the seminar. You must be able to answer any questions about the project, your chosen approaches, the feature you implemented, and the code you wrote. Your defence will directly affect your Lab II score.
Nov 21–27
Seminar
Talks

Conference

Listen to talks from your peers! Giving a talk earns bonus points. There will be no regular seminar that week.
Nov 28–Dec 4
Seminar
Details will be added later
Dec 5–11

Rest and exam preparation

There will be no seminar this week. Use the time to rest and prepare for the exam.
Dec 12–18

EXAM