Space Python Loading Python…

Iterating Over Dictionary

 
0:00 / 0:00

Challenge

Practise what this example shows with these challenges.

Print the manifest

Write the codeEasy 2 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 the challenge

Go launches only

Write the codeEasy 2 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 the challenge

Entries per level

Write the codeEasy 2 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 the challenge

Log analyser

Write the codeHard 3 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 the challenge

Ground pass planner

Write the codeMedium 2 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 the challenge

Alert deduplicator

Write the codeHard 2 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 the challenge

Discussion

Stuck on this example or want to go further? Ask here, or see what others asked.

Log in to ask and reply.

script.py
PythonLn 1, Col 1Spaces: 4
Loading the Python environment…

Separate arguments with commas. They're passed on every Run as sys.argv[1:].