Results for “dictionaries”

Showing 21–30 of 31

  1. Challenge

    Entries per level

    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.

    Write the code Easy 2 stages dictionaries counting get sorted
  2. Challenge

    Index by ID

    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…

    Write the code Medium 2 stages dictionaries indexing lookup in
  3. Challenge

    Lookup table

    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.

    Fix the code Medium 2 stages dictionaries refactoring lookup tables get
  4. 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.

    Write the code Medium 2 stages dictionaries grouping get sorted
  5. Challenge

    Settings with defaults

    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.

    Write the code Medium 2 stages dictionaries copy update defaults
  6. Challenge

    API response

    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…

    Write the code Easy 2 stages dictionaries keys items JSON
  7. Challenge

    Line to record

    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.

    Write the code Easy 2 stages dictionaries lists parsing records
  8. Challenge

    Missing field

    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…

    Fix the code Easy 3 stages dictionaries KeyError get default values