Results for “get”

Showing 1–10 of 32

  1. Challenge

    Missing field

    …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.

    Fix the code Easy 3 stages dictionaries KeyError get default values
  2. Challenge

    Mass by category

    …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
  3. Challenge

    Lookup table

    …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

    Entries per level

    …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
  5. Challenge

    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().

    Fix the code Easy 2 stages collections Counter most_common dictionaries
  6. Challenge

    Signal delay

    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.

    Write the code Medium 3 stages division round // %
  7. Challenge

    Logging instead of print

    …module logs. Give this code its own logger, log = logging.getLogger("fuel") , log through it, and add its name to the format with %(name)s . Switch on debug records for this logger only with…

    Fix the code Medium 2 stages logging debug info warning
  8. Challenge

    Numbered checklist

    …3. Arm the abort system 4. Switch to internal power 5. Get a go from Mission Control enumerate(checklist, start=1) gives pairs of a number and an item. Unpack them in the loop: for number, item in…

    Write the code Easy 2 stages for loop enumerate start lists
  9. Challenge

    Mission elapsed time

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

    Write the code Medium 2 stages datetime timedelta ISO 8601 time zones