Results for “get”

Showing 1–10 of 57

  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. Article Python Fundamentals

    A Practical Guide to Getting Started with Programming

    …(it's a really simplified explanation, but I'm sure you get what I mean). With Python, you write these instructions using English words and some symbols that are later interpreted so your PC can…

  6. 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
  7. 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 // %
  8. 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
  9. Article Mini projects

    Medical dispenser - Don’t trust the user

    …clock by three hours and ask again. It works, and Grace gets his medication, smugly noting " What a stupid system. " Reading this brought back memories from the late '90s when I'd set my PC's date…

  10. Article Mini projects

    Managing Astronaut Medical Data with Python

    …pady=10) def add_astronaut(self): name = self.name_entry.get() age = self.age_entry.get() nationality = self.nationality_entry.get() conn = sqlite3.connect('space_station.db') cursor = conn.cursor()…