Python ยท Practice
Python exercises
20 exercises: 5 easy, 12 medium and 3 hard. Each has a starter file, examples, hints and a solution you can reveal, and your program is checked against every test case. Everything runs in your browser.
- Choose a delivery windowEasy
Classify a parcel into a delivery window with clear Python if, elif and else conditions.
ConditionsNot started
- Dispatch message initialsEasy
Create uppercase initials from a multi-word dispatch message using Python string operations.
StringsNot started
- Market basket totalEasy
Read item prices and quantities, then print the basket total with two decimal places using Python arithmetic.
BasicsNot started
- Parcel cost functionEasy
Write and call a Python function that calculates a parcel charge from weight and distance bands.
FunctionsNot started
- Unique route stopsEasy
Remove repeated bus stops while preserving first-seen order with Python lists and membership checks.
ListsNot started
- After-sales shortfallsMedium
Compute post-sale stock shortfalls for products and report only items that fall below their minimum.
DictionariesNot started
- First repeated checkpointMedium
Detect the first checkpoint visited twice in a route while preserving the route's travel order.
SetsNot started
- Inventory movement tallyMedium
Aggregate stock movements by product and print a sorted Python dictionary report.
DictionariesNot started
- Longest reading streakMedium
Find the longest run of reading days from a compact activity string using a Python loop.
LoopsNot started
- Merge visitor countsMedium
Merge two counters of venue visits while preserving totals for visitors seen in either source.
DictionariesNot started
- Safe reading averageMedium
Parse sensor tokens safely in Python and average only valid numeric readings using exception handling.
ExceptionsNot started
- Shared route stopsMedium
Find the stops shared by two bus routes without losing the first route's order.
SetsNot started
- Shipping code normalizerMedium
Normalize mixed-case shipping codes, remove formatting hyphens and emit distinct codes alphabetically.
StringsNot started
- Stock movement ledgerMedium
Aggregate signed warehouse movements per SKU and produce a deterministic inventory change report.
DictionariesNot started
- Valid order totalMedium
Validate quantity and integer-cent price rows before summing order value and counting rejected rows.
ExceptionsNot started
- Valid sensor averageMedium
Average only valid bounded sensor readings and report how many malformed readings were rejected.
ExceptionsNot started
- Word frequency reportMedium
Count repeated words with a Python dictionary and print a deterministic alphabetical frequency report.
DictionariesNot started
- Busiest sales daysHard
Find the earliest fixed-width sales window with the greatest total using a sliding sum.
ListsNot started
- Restock priority reportHard
Calculate stock shortfalls and rank urgent restocks with deterministic tie-breaking.
DictionariesNot started
- Shelf pair targetHard
Find the lexicographically smallest pair of distinct shelf weights that matches an exact target.
ListsNot started