Python practice
Practice with small, real problems.
Level 201 · 16 lessons · 21 practice labs
Lessons
Language basics
- Practice: strings and loops: You strengthen your skills in handling text and writing loops by solving small, realistic problems.
- Practice: functions and scope: You strengthen your skills in writing functions and in understanding where variables are valid (scope) with small problems.
- Practice: lists, dictionaries, sets: You strengthen your skill at choosing lists, dictionaries and sets in the right place by solving small problems.
- Practice: comprehensions and generators
- Short task: compare two staff lists
Data and files
- Practice: regular expressions and parsing: You practise pulling the information you want out of log lines with regular expressions (text patterns) on small problems.
- Practice: files, CSV and JSON: You strengthen your skills in reading and writing files, CSV and JSON through small, realistic tasks.
- Practice: date ranges and durations
- Practice: reading data that may be broken
- Short task: a monthly expense report from a CSV
Design and algorithms
- Practice: classes and decorators: You practise writing classes and adding extra behaviour to functions with decorators through small problems.
- Practice: small algorithms: You build your skill at thinking through small algorithms such as searching and sorting, step by step, and coding them.
- Practice: recursion and directory trees
- Practice: HTTP requests and web data: You strengthen your skill at fetching and processing data from web addresses with HTTP requests on small, realistic problems.
- Short task: find the broken links on a page
Capstone
- Capstone: a ticket tracker that stores its data in a file
Practice labs
- Merging overlapping booking intervals: Merge overlapping and adjacent intervals in Lavanta Otel's meeting room bookings, list the free hours and pass the randomised tests.
- Finding words two texts share: Write a function that ignores punctuation and case and returns the words two texts share in alphabetical order.
- Yielding records in batches: Write a generator function that yields a long stream of records in batches of a hundred without filling memory.
- Fixing a counter bug in a closure: Find and fix the bug where callbacks created in a loop all return the same value, plus a missing nonlocal, and pass the tests.
- Normalising phone numbers: Write a function that extracts phone numbers written in different styles with a regular expression and formats them as '+90 5XX XXX XX XX'.
- Converting CSV to JSON with types: Write a function that exports Bulutsu Yazılım's licence CSV to JSON, converting number, date and boolean fields to the right types.
- Finding gaps in a date series: Write a function that finds the missing days and the longest gap in a list of daily backup dates.
- Sorting out broken JSON lines: Write a function that separates broken, incomplete and wrongly typed lines in a JSON-lines file with reasons and processes the valid ones.
- Writing a binary search on a sorted list: Write your own binary search that returns the position of a value in a sorted price list, or where it should be inserted.
- Summing a nested list recursively: Write a recursive function that sums the amounts in nested order lists of unknown depth.
- Printing a folder tree with indentation: Write a recursive function that turns a folder structure into indented text like the tree command, including empty folders.
- Speeding up slow recursion with a cache decorator: Write your own caching decorator for a recursive function that counts ways to climb stairs; the tests enforce a time limit on large inputs.
- Collecting page titles: Write a function that collects the HTML titles of pages on the lab web target with html.parser and returns URL-to-title pairs.
- Turning an HTML table into records: Write a function that reads the price table on the lab web target, turns each row into a dictionary and converts the numeric fields.
- Walking a paginated list to the end: Write a function that follows 'next' links through every product page, never visits a page twice and sends at most N requests.
- Finding added and removed lines: Compare two versions of a settings file with set operations and report the lines found only in the old one and only in the new one in their original file order.
- Matching similar documents by shared-word ratio: Compute the Jaccard ratio between the word sets of documents and pair each document with its most similar one above a threshold; tests cover empty documents and equal ratios.
- Yielding file lines with a generator: Write a generator function that yields the non-empty lines of a large file one at a time, stripped, without loading the whole file into memory.
- Writing a sliding-window generator: Write a sliding-window generator that works in a single pass over any iterable and keeps only a window's worth of items in memory; the tests feed it a one-shot stream.
- Making a counter with a closure: Write make_counter using nonlocal so it produces counter functions that increase by one per call and keep their own count, with two counters never affecting each other.
- Building range validators with closures: Write a factory that returns validator functions remembering a lower and upper bound, with each validator keeping its own count of rejected values.
About this course
Practice with small, real problems.
What you will learn
- Language basics
- Data and files
- Design and algorithms
- Capstone
Prerequisites
Finishing the level 101 courses of the same path, or knowing those topics, is enough.
Lab environment
Lessons run in your own Kali Linux terminal in the browser, connected to a private lab network. Nothing to install.
Frequently asked questions
- Is this course right for my level?
- The course is at level 201; it assumes you know the topics of the lower-level courses.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.