Results for “print”

Showing 141–150 of 150

  1. Challenge

    Index by ID

    …each cargo ID to its record, then look up wanted in it and print the record: CG-0045 | CO2 scrubber cartridges | life support | 31.3 kg Start with by_id = {} and, for each record, store it under…

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

    Undo and history

    Extend the working cargo console: record every change to the hold in a history list and show it with a history command, then add undo, which takes the last change off the history and reverses it.

    Write the code Hard 2 stages project lists stack append
  3. Challenge

    Copy-pasted blocks

    Replace three copy-pasted tank-status blocks with a list of (name, level) pairs and one loop, keeping the output exactly the same, then add a fourth tank with a single list item and list the low…

    Fix the code Medium 2 stages refactoring for loop tuples lists
  4. Challenge

    Parser function

    Move the feed parser from "Line to record" into parse_line(line), which returns the record dict, then let it return None for blank, comment and damaged lines so the loop only keeps real records.

    Fix the code Medium 2 stages functions return dictionaries None
  5. Challenge

    Unit converter

    Write convert(), which looks a unit pair up in a table of factors, works the other way round by dividing, and refuses unknown units or missing pairs with a clear ValueError, then extend the table with…

    Write the code Medium 2 stages project dictionaries tuples as keys functions
  6. Challenge

    Packing crates

    Work out how many 12-slot crates 100 sample tubes fill with // and %, then how many crates they need and how full the last one is, including the case where the tubes fit exactly.

    Write the code Medium 2 stages floor division modulo rounding up //
  7. Challenge

    Alert deduplicator

    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…

    Write the code Hard 2 stages project dictionaries tuples as keys grouping
  8. Challenge

    Counter

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

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

    Extra log fields

    Extend format_log() from "Log formatter function" with **fields, so any extra keyword arguments are added to the line as key=value pairs, then pass whole dicts of fields into it with ** at the call.

    Write the code Medium 2 stages functions **kwargs keyword arguments dictionaries