Real JSON
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 the challengePractise what this example shows with these challenges.
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 the challengeTurn 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 the challengeParse 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 the challengeExtend 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 the challengeWrite 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 the challengePoint 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 the challengeSimulate 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 the challengeRefactor 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 the challengeRefactor 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 the challengeThe 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 the challengeA 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 the challengeParse 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 the challengeStuck on this example or want to go further? Ask here, or see what others asked.
Log in to ask and reply.
Separate arguments with commas. They're passed on every Run as sys.argv[1:].
Log in or create a free account to save your code and share it with a link. Your code will be waiting here when you come back.