Python labs - 24 hands-on challenges
Solve 24 real Python challenges in an isolated container in your browser. No setup, no fake shells.
- Fix the Broken Receipt - beginner · Convert text to a number so a price calculation actually works.
- Build a Proper Greeting - beginner · Use string methods to format a name correctly and build a welcome message.
- Compute the Real Average - beginner · Fix a list-indexing bug so an average is computed from every score, not just one.
- Grade Every Student, Not Just One - beginner · Fix a loop that never advances and an out-of-order if/elif chain.
- Count the Real Errors - beginner · Actually open and read a log file instead of hardcoding the answer.
- Write Your First Function - beginner · Implement a palindrome checker from scratch.
- Total the Whole Inventory - beginner · Loop over a dictionary of dictionaries instead of reading one hardcoded key.
- Survive Bad Input - intermediate · Wrap risky code in try/except so one bad value doesn't crash the whole run.
- Rewrite It as a Comprehension - intermediate · Replace a manual filter-and-transform loop with a single list comprehension.
- Import the Right Module - intermediate · Fix a wrong module name and use it correctly across two files.
- Actually Parse the JSON - intermediate · Use json.load() instead of reading a config file as raw text.
- Stop the Account Going Negative - intermediate · Fix a class method so it refuses withdrawals it can't cover.
- Build a Real Command-Line Tool - intermediate · Replace fragile sys.argv reads with proper named, typed arguments.
- Isolate Your Project's Packages - intermediate · Create a virtual environment and record its dependencies.
- Fix the Decorator That Eats Return Values - advanced · Make a logging decorator actually call the wrapped function and return its value.
- Fix the Lock That Never Releases - advanced · Add __exit__ so a resource lock always releases, even after a crash.
- Fix the Calculator, Not the Tests - advanced · Make a real pytest suite pass by fixing the code under test.
- Automate a Real Backup Safely - advanced · Replace an unsafe os.system() call with subprocess.run().
- Deduplicate Python Attendees - beginner · Use tuple unpacking and a set to filter unique registrations.
- Repair the Server Family - intermediate · Use inheritance, overriding, initialization, and a friendly string representation.
- Stream Error Lines - advanced · Replace a memory-hungry list with a generator that yields one result at a time.
- Build a UTC Audit Report - intermediate · Extract structured fields with named regex groups and record a timezone-aware timestamp.
- Create the Healthy Service Report - intermediate · Read real CSV rows with pathlib and write valid JSON.
- Raise a Useful Deployment Error - advanced · Create and raise a domain-specific exception instead of returning an ambiguous flag.