Python challenges

Fix broken code or write it from scratch. Every challenge has stages, and tests check your code right in the browser.

Mission Control online

Write the codeEasy2 stages

Print status lines that a monitoring system reads character by character. A first Python challenge on exact output with print(), right in your browser.

Start

Broken boot script

Fix the codeEasy3 stages

The flight computer won't boot: a quote and a bracket are missing. Read the SyntaxError, find the broken line and fix it. A beginner Python debugging challenge.

Start

Environment check

Write the codeEasy3 stages

Every useful bug report starts with the Python version. Ask Python for it with the platform and sys modules and print it the way python --version does.

Start

Wrong line commented out

Fix the codeEasy2 stages

A real check is commented out and a debug line is left on. Use # comments to put the pre-flight checklist script back in order. A beginner Python challenge on comments.

Start

Read the error

Fix the codeEasy3 stages

The flight log script won't run. Read the error message, go straight to the line it names and fix it. Learn to debug Python syntax errors the way programmers do.

Start

Log line format

Write the codeEasy2 stages

Turn values into a log line like [T+00:12:05] INFO Engines nominal with an f-string, then build the timestamp from numbers with zero padding.

Start

CSV row

Write the codeEasy3 stages

Write a telemetry reading as a CSV row with print() and sep, add a header row, then switch to tabs for pasting into a spreadsheet. Real data formats from print().

Start

Progress on one line

Write the codeEasy3 stages

Make two prints share one line, like Uploading flight plan... done, by changing how print() ends. A Python challenge on print(end=...) for progress messages.

Start

Units and separators

Write the codeEasy3 stages

Print 7.6612 as Speed: 7.66 km/s, 1234567 as Mass: 1,234,567 kg and a fuel fraction as a percentage, using format specs in f-strings.

Start

Aligned status board

Write the codeMedium3 stages

Print systems and their states in aligned columns with width specifiers like {name:<12}, then add a header and a right-aligned column of readings.

Start

Path in a config

Fix the codeEasy2 stages

A Windows path prints wrong because \n and \t inside it turn into a new line and a tab. Fix it with a raw string, then handle a path that ends with a backslash.

Start

JSON-looking payload

Fix the codeMedium2 stages

Print a JSON-style status message full of double quotes and an apostrophe exactly, then build it with an f-string that needs literal curly braces.

Start

Alert banner

Write the codeMedium3 stages

Print an alert between two 30-character borders from a single f-string with \n, then add more lines and centre the title in the border.

Start

Mission config

Write the codeEasy3 stages

Predict, investigate and extend a mission config held in variables: text, whole numbers, decimals and True/False. A PRIMM challenge on Python data types.

Start

Magic numbers

Fix the codeEasy3 stages

Turn the bare 9.81 and 1000 in a weight report into named constants without changing the output, then write a Mars version with constants from the start.

Start

Readings that won't add

Fix the codeEasy3 stages

Two sensor readings add up to 12080 instead of 200 because they arrived as text. Predict it, find out why and fix it with int(), then add decimal readings with float().

Start

Status message crash

Fix the codeEasy3 stages

A status line crashes with a TypeError because it joins text and a number with +. Predict it, read the error, fix it with str(), then build a docking status line.

Start

Names that explain

Fix the codeEasy3 stages

A cargo calculation uses a, b, x2 and tmp. Predict it, work out what each name holds, rename them so the code explains itself, then write a fuel check with good names.

Start

What arrived?

Write the codeEasy3 stages

A sensor packet mixes text, numbers and text that only looks like numbers. Predict what type() shows, find the values that need converting, then convert a packet yourself.

Start

Round or cut?

Write the codeMedium3 stages

int() cuts the decimals off, round() rounds, and round(2.5) gives 2. Predict the difference, investigate Python's rounding rule, then round a fuel reading two ways.

Start

Float surprise

Write the codeEasy3 stages

Predict 0.1 + 0.2, see the 0.30000000000000004 that every programmer meets once, then round it for display the way fuel gauges and dashboards do.

Start

Running totals

Write the codeEasy3 stages

Predict how -= and += change a fuel level, track it through three burns and a top-up, then follow a battery through one orbit. A PRIMM challenge on updating variables.

Start

Duration formatter

Write the codeEasy3 stages

Split 100,000 seconds of mission time into hours, minutes and seconds with // and %, pad it to a 27:46:40 clock, then add days in the DDD/HH:MM:SS format.

Start

Tank level

Write the codeEasy2 stages

Turn a tank's capacity and contents into a fill percentage with one decimal place, then draw the crew display's ten-segment gauge with string repetition and int().

Start

Wrong average

Fix the codeEasy3 stages

An average of three hull temperatures comes out at 47 °C when every sensor reads about 21. Predict it, find where the brackets are missing, fix it, then work out an average speed.

Start

Signal delay

Write the codeMedium3 stages

Divide a distance by the speed of light to get the radio delay to a Mars orbiter, show it in whole minutes and seconds, then add the round trip without doubling a rounding error.

Start

Packing crates

Write the codeMedium2 stages

Work out how many 12-slot crates 100 sample tubes fill with // and %, then how many crates they need and how full the last one is, including the case where the tubes fit exactly.

Start

Fuel for a burn

Write the codeEasy2 stages

Ask for an engine burn length with input(), turn it into a number with float() and work out the propellant it uses, then read the tank level too and show what the burn leaves.

Start

input() returns text

Fix the codeEasy3 stages

A crew count read with input() crashes when 1 is added to it. Predict the crash, find out what input() really returns, fix it with int(), then write a packing tool that reads two numbers.

Start

Waypoint distance

Write the codeEasy2 stages

Work out the straight-line distance between two waypoints on a rover map with ** 2 and ** 0.5, then add a third waypoint and print each leg and the length of the whole route.

Start

Downlink time

Write the codeMedium3 stages

Read a file size in MB and a link speed in Mbit/s with input(), work out the transfer time without forgetting the 8 bits in a byte, show it in minutes and seconds, then count the ground station passes.

Start

Unit mix-up

Fix the codeEasy3 stages

A trajectory total adds a leg in miles to legs in kilometres. Predict the total, find the leg that doesn't fit, convert it with a named constant, then convert a lander's feet per second to metres.

Start

Normalise a command

Write the codeEasy3 stages

Turn " Launch " into launch with strip() and lower(), check it against the command list, then accept underscores and dashes too, so commands match however operators type them.

Start

Decimal comma

Fix the codeEasy3 stages

An operator types 42,5 and float() crashes with a ValueError. Predict it, find out why, accept both commas and dots with replace(), then read pressures written like 1 013,25.

Start

Parse a telemetry line

Write the codeEasy2 stages

Split a telemetry reading like 2026-03-14T09:30:05Z,ENG-2,412.5,C into its four fields with split(), print each with a label, then turn the value into a number and convert it to kelvin.

Start

Sensor ID parts

Write the codeMedium2 stages

Split a sensor ID like ENG-2 into its subsystem and its unit number as an int, work out the next ID, then handle subsystems with a dash in their name using rsplit().

Start

Date and time from a timestamp

Write the codeEasy2 stages

Slice the date and the time of day out of an ISO timestamp like 2026-03-14T09:30:05Z, then rebuild it in the day.month.year format used in Poland and much of Europe.

Start

Off-by-one slice

Fix the codeEasy3 stages

A slice meant to take the number from the container tag CG-0042 gives -004. Predict it, work out where indexes start and where a slice ends, fix it, then slice a sample label yourself.

Start

Search the log

Write the codeMedium2 stages

Check whether a mission log line contains ERROR with in, find where it starts with find(), including the -1 it gives when there is nothing to find, then slice out the error message.

Start

Count warnings

Write the codeMedium3 stages

Count the entries and the WARN lines in a multi-line mission log with count(), fix the count when a message mentions WARN itself, then summarise the log by level.

Start

Redact the access code

Write the codeMedium2 stages

Replace all but the last four characters of an access code with * using len(), slicing and string repetition, then find a code inside a log line and mask it there before the line is saved.

Start

File name from data

Write the codeEasy3 stages

Build eng-2_2026-03-14.csv from a sensor ID and a date, then turn a name like Star Tracker A into a safe file name, and put the file in a folder of its own.

Start

Accept the right files

Write the codeEasy2 stages

Check whether a path starts with telemetry/ and ends with .csv using startswith() and endswith(), see why in isn't enough, then clean up paths with Windows backslashes, capitals and spaces first.

Start

Strings don't change

Fix the codeEasy3 stages

code[0] = "X" stops with a TypeError, because Python strings can't be changed. Predict the crash, find out what methods and slices really give, build a new string instead, then swap a letter in the middle of a code.

Start

Telemetry report

Write the codeMedium2 stages

Extend the parser from "Parse a telemetry line" to read three readings from a multi-line feed, print each as one row, then turn them into a report with a header and aligned columns.

Start

Alert level

Write the codeEasy2 stages

Turn an engine temperature into OK, WARN or CRITICAL with if, elif and else and two thresholds, check the exact boundaries, then store the level in a variable for a status line.

Start

Assignment in a condition

Fix the codeEasy3 stages

An oxygen check uses = instead of == and has a line that isn't indented, so Python refuses to run it. Predict what happens, fix both errors one after the other, then write an if/else check yourself.

Start

Unreachable branch

Fix the codeEasy3 stages

A vibration check reports WARN for a reading of 63 because its elif conditions are in the wrong order, so CRITICAL can never run. Predict it, find the dead branch, fix the order, then write a four-level chain.

Start

Launch commit criteria

Write the codeEasy2 stages

Clear a launch only if the wind is under 30 km/h, there is no lightning and range safety reports GO, using and and not, then print every rule that is holding the launch.

Start

Flag from config text

Fix the codeEasy3 stages

A config file says dry_run is False, yet bool("False") turns it into True and the engine simulates instead of firing. Predict it, find out why, compare the text instead, then read yes/no settings typed by hand.

Start

Validate a command

Write the codeEasy2 stages

Read a console command with input(), accept start, stop and status in any case with an if/elif chain, print Unknown command for anything else, then handle empty input and show what was typed.

Start

Missing reading

Write the codeMedium2 stages

Extend the alert check from "Alert level" so a sensor that didn't answer, None, prints NO DATA instead of crashing, without treating a real 0 as missing, then do the same for an empty field in a telemetry line.

Start

Safe mode

Write the codeMedium2 stages

Put the spacecraft into safe mode when the battery is under 20% or contact has been lost for over 10 minutes, using or, then name the rule that fired with boolean variables and an if/elif chain.

Start

Flatten nested ifs

Fix the codeMedium2 stages

Refactor a docking check built from three nested ifs into one condition joined with and, keeping the output exactly the same, then rewrite it as a flat if/elif chain that reports the first check that failed.

Start

Ground station pick

Write the codeEasy2 stages

Choose New Norcia, Cebreros or Malargüe from the longitude under a spacecraft with an if/elif chain of ranges, then accept longitudes from 0 to 360 and reject values that can't be longitudes.

Start

Upload router

Write the codeEasy2 stages

Route an uploaded file to images, telemetry or rejected by its extension with an if/elif chain and endswith(), then cope with capitals, spaces and more extensions without changing the name that is shown.

Start

Crew roster

Write the codeEasy2 stages

Print the commander, the newest member and the crew size from a list with [0], [-1] and len(), then add the second in command and the whole roster joined into one line.

Start

Roster changes

Write the codeEasy2 stages

Apply a day's crew changes to a list: append() a new member, insert() a backup at position 1, remove() someone who left, then pop() the newest member and print who was reassigned.

Start

sort() returns None

Fix the codeEasy3 stages

crew = crew.sort() leaves the roster as None. Predict it, find out what sort() really gives back, fix it by sorting in place, then sort readings from highest to lowest and keep the top three.

Start

Sorted copy

Write the codeEasy2 stages

Print the roster A–Z for a report with sorted() while the sign-up order stays exactly as it was, then sort names like de Vries and van Dijk correctly with key=str.lower.

Start

Last five readings

Write the codeEasy2 stages

Show only the five most recent CO2 readings with the slice [-5:], as a dashboard does, then add a new reading and print how much the level changed across the window.

Start

Missing index

Fix the codeEasy3 stages

readings[5] on a list of five readings stops with an IndexError. Predict it, work out the valid indexes with len(), fix it with [-1], then print the first, middle and last readings for any length.

Start

Landing site

Write the codeEasy2 stages

Store the Perseverance landing site as a (lat, lon) tuple, unpack it into two variables in one line and print both to four decimals, then show it the way maps do, with N, S, E and W.

Start

Readings summary

Write the codeEasy2 stages

Summarise a list of engine readings with min(), max() and a mean from sum() / len(), then add the spread and make the summary cope with an empty list instead of crashing.

Start

Approved payloads

Write the codeEasy2 stages

Check whether a payload ID is on the approved list with in, which matches whole items rather than parts of text, then normalise IDs typed by hand and print a clear cleared or not-cleared message.

Start

Manifest line

Write the codeEasy2 stages

Unpack an (id, item, mass_kg) tuple into three named variables and print a cargo manifest line, then fix the ValueError when the manifest adds a fourth field.

Start

Backup that isn't

Fix the codeMedium3 stages

backup = crew gives one list two names, so removing someone from the backup removes them from the live roster too. Predict it, prove it with is, fix it with copy(), then plan a crew swap on a real copy.

Start

Check every reading

Write the codeEasy2 stages

Extend the OK/WARN/CRITICAL check from Alert level so a for loop runs it over every temperature in a list, then count the WARN and CRITICAL readings for a summary line.

Start

Numbered checklist

Write the codeEasy2 stages

Print a pre-flight checklist numbered from 1 with enumerate(list, start=1), then tick off the items the crew has already done with [x] and leave the rest as [ ].

Start

Parse the whole feed

Write the codeEasy2 stages

Go through a block of telemetry line by line with splitlines(), split each line at the commas and print the sensor and value, then unpack the four fields and show the clock time too.

Start

Skip blanks and comments

Write the codeMedium2 stages

Extend the feed parser so continue skips blank lines and comment lines, then report damaged lines with too few fields instead of crashing, with a count of parsed and damaged lines.

Start

One orbit short

Fix the codeEasy3 stages

A loop over range(1, 10) logs nine orbits of a ten-orbit flight. Predict the last line, find out where range() stops, fix it with ORBITS + 1, then list every third orbit with a range() step.

Start

Never-ending wait

Fix the codeEasy3 stages

A while loop waits for the antenna signal but never moves on to the next reading, so it never ends. Predict it, find the stuck counter, fix it, then write a wait that gives up when the readings run out.

Start

First error

Write the codeEasy2 stages

Scan the mission log for the first ERROR entry, print its line number with enumerate() and stop there with break, then report how many lines were checked, or that there were no errors at all.

Start

Filter the log

Write the codeMedium2 stages

Go through the mission log and build a new list holding only the WARN and ERROR entries with append(), then let a minimum level decide what counts, the way logging tools filter by severity.

Start

Retry the uplink

Write the codeMedium2 stages

Send a command up to three times, taking each result from a list of simulated radio replies, and stop at the first success with break; then wait 2, 4, 8 seconds between attempts, as real retry code does.

Start

Paged results

Write the codeMedium2 stages

Merge three pages of launch results into one list with extend(), then fetch page after page in a while loop and stop at the first short page, the way paginated API responses are read.

Start

Countdown with holds

Write the codeEasy2 stages

Print a launch countdown from T-10 to T-0 with range(10, -1, -1), adding a hold line at every second listed in holds, then scrub the launch at a given second with break, or print Liftoff! at the end.

Start

Names with values

Write the codeEasy2 stages

Print each sensor name with its reading by looping over two lists together with zip(), then add a third list of units and warn when the lists don't have the same length, since zip() quietly stops at the shortest.

Start

Copy-pasted blocks

Fix the codeMedium2 stages

Replace three copy-pasted tank-status blocks with a list of (name, level) pairs and one loop, keeping the output exactly the same, then add a fourth tank with a single list item and list the low tanks.

Start

Debris grid

Write the codeMedium2 stages

Scan a radar grid stored as a list of strings with a loop inside a loop, print the row and column of every # with enumerate(), then turn the loops around to find the columns that are clear all the way through.

Start

Line to record

Write the codeEasy2 stages

Extend the feed parser so it stores every reading as a dict with time, sensor, value and unit in a list of records, then let other code pick out one sensor's readings by key.

Start

API response

Write the codeEasy2 stages

Print the name, provider and status of a launch from a dict shaped like a launch-API response, then list every field the response has with items(), the way you'd inspect an API you haven't used before.

Start

Missing field

Fix the codeEasy3 stages

Reading launch["pad"] stops with a KeyError when the API hasn't assigned a pad yet. Predict it, check the keys with in, fix it with get() and a default, then print a list of launches with defaults for any missing field.

Start

Nested response

Write the codeEasy2 stages

Print the rocket's name and the first mission patch URL from a nested launch response by chaining keys and indexes, then add the operator and orbit and cope with a launch that has no patches yet.

Start

Print the manifest

Write the codeEasy2 stages

Print one cargo manifest line for every record in a list of dicts, reading each field by key, then add up the masses in the same loop for a total line.

Start

Go launches only

Write the codeEasy2 stages

Print only the launches whose status is Go from a list of launch dicts, then collect the others with their status into one "not go yet" line, or none.

Start

Mass by category

Write the codeMedium2 stages

Add up the cargo mass of each category into a dict with totals[category] = totals.get(category, 0) + mass, then list the categories from heaviest to lightest with their share of the load.

Start

Entries per level

Write the codeEasy2 stages

Count the mission log's entries per level, INFO, WARN and ERROR, in a dict of counters, then count any level at all with get() when DEBUG lines turn up, and print the levels in alphabetical order.

Start

Lookup table

Fix the codeMedium2 stages

Replace a nine-branch elif that maps planets and the Moon to surface gravity with a dict and one get() lookup, keeping the output exactly the same, then loop over the dict for a weight table.

Start

Settings with defaults

Write the codeMedium2 stages

Build a user's settings by copying the defaults and laying their own values on top with update(), so any setting they haven't changed falls back, then warn about unknown keys instead of saving them.

Start

Duplicate events

Write the codeMedium2 stages

Print each capsule event once, keeping the first copy, by checking every ID against a set of IDs already seen, then report which IDs came in more than once.

Start

Manifest diff

Write the codeEasy2 stages

Compare yesterday's and today's cargo IDs with set difference to print what was added and what was removed, then count what stayed with an intersection and print none for an empty change.

Start

Airlock permissions

Write the codeMedium2 stages

Check that a crew member holds every permission an airlock action needs with needed <= granted, list what is missing with needed - granted, then check every action in a dict of required permissions.

Start

Index by ID

Write the codeMedium2 stages

Build a dict that maps every cargo ID to its record, so any item is found with one lookup instead of a search through the list, then answer a list of requests, including an ID that isn't on the manifest.

Start

Log formatter function

Fix the codeEasy2 stages

Move the mission log's f-string into format_log(t, level, msg), a function that returns the line instead of printing it, then fix the alignment of every log line with one change inside the function.

Start

Parser function

Fix the codeMedium2 stages

Move the feed parser from "Line to record" into parse_line(line), which returns the record dict, then let it return None for blank, comment and damaged lines so the loop only keeps real records.

Start

Prints instead of returns

Fix the codeEasy3 stages

to_kelvin() prints its result instead of returning it, so the caller gets None. Predict the last line, find out what the function gives back, fix it with return, then write a conversion function that returns.

Start

Silent branch

Fix the codeEasy3 stages

status_light() returns None for Scrub because that branch sets a variable but never returns it. Predict the last line, find which statuses give None, make every path return, then write a function where every path returns.

Start

Validate a cargo record

Write the codeMedium2 stages

Write validate_cargo(item), which returns a list of everything wrong with a cargo record: missing fields and a negative mass, then a cargo ID that doesn't match the CG- and four digits format. An empty list means the record is fine.

Start

Docstring and type hints

Write the codeEasy2 stages

Add a docstring to fuel_needed() that says what it returns and what the reserve means, then add type hints for its parameters and return value; the tests read both from the function itself.

Start

Sort by a field

Write the codeEasy2 stages

Sort launches by date with sorted() and a small function that returns each launch's date, then sort the cargo manifest heaviest first with a key function and reverse=True.

Start

Test the alert levels

Write the codeMedium2 stages

Write assert checks for alert_level(): one temperature for each level first, then the values exactly on each threshold and just below them, so a > written instead of >= can't slip through.

Start

Edge cases

Write the codeMedium2 stages

Write assert checks for mean(): an ordinary list and a list with one value first, then the edge cases, an empty list that should give None and lists with negative values, so broken copies of the function can't pass.

Start

Test the parser

Write the codeMedium2 stages

Write assert checks for parse_line() from "Parser function": the whole record for a good line first, then None for a blank line, a comment and a line with a missing field, so a broken parser can't pass.

Start

Extract a function

Fix the codeEasy2 stages

Move a 3D distance calculation that is copied for three waypoints into distance_km(a, b), keeping the output exactly the same, then put the waypoints in a dict and find the nearest one with the same function.

Start

Guard clauses

Fix the codeMedium2 stages

Rewrite the four nested ifs in can_dock() as guard clauses that return a reason as soon as a check fails, keeping every answer the same, then add a new docking rule as one more guard with a default parameter.

Start

Changed the caller's list

Fix the codeMedium3 stages

add_reading() appends to the list it receives, so the caller's stored readings change too. Predict the first line, prove both names share one list, fix it by returning a new list, then write a filter that leaves its input alone.

Start

Summary function

Write the codeMedium2 stages

Write summarise(readings), which returns the count, min, max and mean of a list of readings as one dict, then make it handle a pass with no data and round the mean, so any program can use the summary.

Start

Swapped arguments

Fix the codeEasy3 stages

A call to schedule_launch() passes the pad where the rocket belongs, and the board says a launch pad is flying. Predict the line, find which parameter got which value, fix it with keyword arguments, then make calls that can't be swapped.

Start

Sensible defaults

Write the codeEasy2 stages

Give send_command(cmd, retries=3, timeout=5.0) default values so callers only pass what differs, call it three different ways, then add a new priority parameter without breaking any existing call.

Start

Any number of values

Write the codeEasy2 stages

Write average(*values), which accepts any number of numbers, call it with loose values and with a list unpacked by *, then add a keyword-only decimals option after *values and return None when there are no values.

Start

Extra log fields

Write the codeMedium2 stages

Extend format_log() from "Log formatter function" with **fields, so any extra keyword arguments are added to the line as key=value pairs, then pass whole dicts of fields into it with ** at the call.

Start

Shared default list

Fix the codeMedium3 stages

add_sample(sample, log=[]) remembers samples from earlier calls, because the default list is created once and shared. Predict it, prove the calls share one list, fix it with None as the default, then write a function that hands out a fresh list each time.

Start

Prove the fix

Write the codeMedium2 stages

Write assert checks for the fixed add_sample() that would have caught the shared default list, then add checks that a log passed in is still the one that gets the sample, so a "fix" that breaks that can't pass either.

Start

Launch counter crash

Fix the codeMedium3 stages

record_launch() adds 1 to a global counter and stops with an UnboundLocalError. Predict it, find out why Python treats the name as local, fix it by passing the count in and returning the new one, then write a fuel function the same way.

Start

Shadowed fuel

Fix the codeMedium3 stages

refuel() assigns to fuel_kg inside the function, creating a local variable and leaving the global fuel unchanged. Predict the last line, compare both values, fix it by returning the total, then write a function that uses only its parameters.

Start

Confirm by name

Write the codeMedium2 stages

Make abort(reason, *, confirm) refuse to run unless confirm=True is passed by name: a bare * makes confirm keyword-only and required, then an is True check refuses values that are merely truthy, such as "yes".

Start

Read the traceback

Fix the codeEasy2 stages

A Python program stops with a traceback. Read it from the bottom up to find the error, the function and the line, fix the bug there, then follow a longer traceback through four calls to a second bug.

Start

Safe number input

Write the codeEasy2 stages

The burn length is typed in by hand, and a typo stops the program with a ValueError. Catch it with try and except, keep asking until the input is a number, then also turn away zero and negative lengths.

Start

Survive bad lines

Write the codeMedium2 stages

Extend the feed parser from "Skip blanks and comments": a faulty sensor sends ERR and float() stops the program. Skip lines that fail to convert and count them, then let one try cover short lines too and print each error.

Start

Catch what you expect

Fix the codeMedium3 stages

A bare except: reports every fuel reading as bad, because it also catches a NameError from a typo. Predict the last line, find the hidden error, catch only ValueError and fix the typo, then write a parser that lets other errors through.

Start

Clear error messages

Write the codeMedium2 stages

fuel_needed() quietly returns negative fuel for a negative burn length. Make it raise ValueError with a message that shows the bad value, then raise TypeError, checked first, when the length isn't a number at all.

Start

Test the error

Write the codeMedium2 stages

Write a check that passes only when fuel_needed(-5) raises ValueError, so a version that returns a value or raises the wrong error fails it, then pin down the message and the lengths that must still work.

Start

Real JSON

Write the codeEasy2 stages

The launch code from "API response" worked on a ready-made dict, but the API really sends JSON text. Turn it into a dict with json.loads(), see what false and null become, then handle a response cut off in transfer.

Start

JSON out

Write the codeEasy2 stages

Turn the day's mission summary dict into JSON text with json.dumps() and indent=2, see what True, False and None become, then keep the station's Polish letters readable and sort the keys so the files compare easily.

Start

Mission elapsed time

Write the codeMedium2 stages

Parse the launch and the latest telemetry timestamp with datetime.fromisoformat(), subtract them to get the mission elapsed time, then time events reported by ground stations in three different time zones.

Start

Live T-minus

Write the codeMedium2 stages

Extend the formatter from "Duration formatter": work out the seconds left from the launch time and datetime.now(timezone.utc) instead of a number typed by hand, then turn it into a countdown() that counts up with T+ after launch.

Start

Log to a file

Write the codeEasy2 stages

Write the day's mission log entries to mission.log with with open(), one per line, read the file back and print it, then add an append_entry() function that adds lines at the end without wiping what is there.

Start

Telemetry from CSV

Write the codeMedium2 stages

Point the feed parser from "Parse the whole feed" at telemetry.csv: read it with csv.DictReader, using the header row for the field names, then find the hottest temperature reading, comparing the values as numbers.

Start

Seeded simulation

Write the codeEasy2 stages

Simulate 100 sensor readings, each with a 5% chance of a glitch, and seed random with 42 so the count is the same on every run and a test can check it exactly, then pick a kind for each glitch with random.choice().

Start

Statistics module

Fix the codeEasy2 stages

Refactor the temperature summary: delete the hand-written mean() and median() and use statistics.mean() and statistics.median() instead, then add the standard deviation and handle passes with too few readings.

Start

Counter

Fix the codeEasy2 stages

Refactor the level counter from "Entries per level": replace the dict and counts.get() with collections.Counter, which starts every key at 0, then list the levels from most to least common with most_common().

Start

Logging instead of print

Fix the codeMedium2 stages

The tank check is full of prints left over from debugging. Replace them with logging calls at the right levels, so debug records stay hidden until switched on, then give the fuel code its own named logger.

Start

Telemetry pipeline

Write the codeHard3 stages

A small but complete data pipeline: read the telemetry CSV, reject rows with unknown sensors or broken values and say why, flag readings outside each sensor's limits, and save a JSON summary for the dashboard.

Start

Launch schedule digest

Write the codeMedium3 stages

Parse the launch schedule from JSON, keep the launches still to come, sort them by their window and print a digest line for each with the time left and any hold, then switch the digest to the live clock.

Start

Manifest validator

Write the codeMedium2 stages

Write problems(item), which lists everything wrong with one cargo item: missing fields, a mass that isn't a number, is 0 or is over the limit. Print a pass or fail line per item, then catch duplicate IDs and check the total load.

Start

Log analyser

Write the codeHard3 stages

Turn the launch-day mission log into answers: parse each line into a dict, count the entries per level and per hour, find the first ERROR, then rank the subsystems by how many warnings they raised.

Start

Command parser

Write the codeMedium2 stages

Write parse_command(), which turns typed commands such as burn 12.5 or set mode safe into tuples and raises ValueError with a reason for anything malformed, then run a whole batch of commands and report each one.

Start

Config loader

Write the codeHard3 stages

Load the downlink module's JSON settings over a copy of the defaults, check each value's type and range and report every problem in one go, then wrap it all in a load_config() that never crashes, even on broken JSON.

Start

Shift rota

Write the codeHard2 stages

Build the station's weekly shift rota: three shifts a day, the crew taken in turn so nobody works two shifts in a row, with a check that proves it, then plan around days off while keeping the work fair.

Start

Ground pass planner

Write the codeMedium2 stages

From today's passes over four ground stations, collect every contact window longer than 8 minutes into one list, sorted by time, then find the longest stretch with no station in contact, counting overlapping passes only once.

Start

Undo and history

Write the codeHard2 stages

Extend the working cargo console: record every change to the hold in a history list and show it with a history command, then add undo, which takes the last change off the history and reverses it.

Start

Unit converter

Write the codeMedium2 stages

Write convert(), which looks a unit pair up in a table of factors, works the other way round by dividing, and refuses unknown units or missing pairs with a clear ValueError, then extend the table with offsets for temperatures.

Start

Alert deduplicator

Write the codeHard2 stages

The monitoring system raises the same alert over and over. Group repeats of an alert that come within 60 seconds of the first into one line with a count, in the order they first appeared, then add the time range and a summary.

Start

Sign-up cleanup

Write the codeMedium2 stages

Clean the crew sign-ups for the analogue mission: trim and capitalise names, lower-case emails, then reject sign-ups with no name or a broken email and drop duplicates by email, saying why for each one.

Start

Daily mission report

Write the codeMedium2 stages

Turn the day's subsystem status into a fixed-width report for the shift handover, with aligned columns and a totals line, then save the same data as a CSV file with csv.DictWriter for the spreadsheet people.

Start

Test the pipeline

Write the codeHard2 stages

The telemetry pipeline is now split into parse_row() and check_limits(). Write assert tests for both, good rows, rejected rows and readings right at a limit, so that each of three planted bugs makes them fail.

Start

Flight software review

Fix the codeHard2 stages

A 40-line pre-burn check has five bugs: a syntax error, a type error, a wrong key, an index out of range and a reversed decision. Read each error to fix the four that crash, then find the one that runs but gives the wrong answer.

Start

Legacy script

Fix the codeHard2 stages

A 70-line engine report repeats the same twelve lines for each engine. Restructure it into parse_feed() and summary_line() with the output unchanged to the character, then add assert tests that would catch either function breaking.

Start