Python

Python Practice

Learn Python the way working code uses it: exact integer arithmetic for money, validation and control flow over raw records, dictionaries for grouping and aggregation, and the functions that compose into a report someone can trust.

python-312Python 3.13
Module 1

Values, Control Flow & Collections

Learn how to do exact integer arithmetic, format numbers for display, branch and filter records with conditionals, and group and rank them with dictionaries.

4
About this challenge

Do the sales team's money arithmetic in integer cents: a line total, a whole-percent change rounded half-up, and a currency label with a thousands separator.

About this challenge

Drop the test rows out of a raw sales export with a loop, and band each sale total as small, medium or large with if/elif/else at the defined boundaries.

About this challenge

Answer 'how much did each product and region sell?' with a dict built in one pass over the records, and rank the best seller by units with an alphabetical tie-break.

About this challenge

Turn a month of raw sale records into one report dict: validated counts, revenue and its label, average sale, revenue by region, the best seller, size-band counts and the change against the previous month.

Module 2

Functions & Text

Learn how to split text with string methods, turn text into numbers safely, format values into fixed-width rows with default arguments, and compose small functions into one report.

4
About this challenge

Split one access-log line into its six fields as a tuple, ignoring stray spaces, upper-casing the method and returning None when the field count is wrong.

About this challenge

Read the log's text columns as numbers: digits to an int, a dash to zero, anything else to None, and a status code to its 2xx-5xx family or 'other'.

About this challenge

Render byte counts as B, KB or MB labels rounded half-up, and build a padded label-and-value row whose width has a default.

About this challenge

Turn a batch of access-log lines into one triage report: malformed counts, status classes, methods, a total transfer label, a ranked path list and a padded table.

Module 3

Custom Types

Learn how to write a class with its own methods, give it the behaviour Python expects when printing and comparing, let a dataclass generate that for you, and compose your own types into one report.

4
About this challenge

Define an Expense class that stores a date, a category and an amount in cents, and answers which month it belongs to, how it reads as a money label and whether it falls in a given month.

About this challenge

Define a Receipt class whose __repr__ prints both of its values and whose __eq__ makes two receipts with the same merchant and total equal while staying unequal to anything that is not a receipt.

About this challenge

Define a Budget dataclass with a category, a limit in cents and a spending field that defaults to zero, and the methods that report what is left, whether the limit has been passed and the effect of spending more.

About this challenge

Compose the given expense, receipt and budget types into a monthly report that counts and totals one month's expenses, breaks them down by category, credits each budget with its own spending and names the largest expense.

Frequently asked questions

4

What will I practice in this path?

3 modules: Values, Control Flow & Collections, Functions & Text and Custom Types.

How many challenges are there, and how hard are they?

12 challenges, all easy.

What does this path run on?

Challenges run on Python 3.13.

Do I need to install anything?

No. Every challenge runs in a browser-based IDE with everything already set up, and your code is graded automatically against a test suite.

We use cookies that are necessary to run Staffcoder, and optional analytics cookies to see which pages get used. Analytics stays off unless you accept. Read our Cookie Policy.