Challenge
Mass by category
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.
Showing 11–20 of 58
Challenge
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.
Challenge
…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.
Challenge
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.
Challenge
…doesn't keep everything at the top level: the rocket is a dict of its own, and the mission holds a list of patch images. The public launch page shows the rocket and the mission patch. Dig the two…
Challenge
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.
Challenge
…"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.
Challenge
…are added to the line as key=value pairs, then pass whole dicts of fields into it with ** at the call.
Challenge
…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.
Quiz
…20 multiple-choice questions on print(), strings, lists, dictionaries, loops and functions, with instant answers.
Challenge
…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().