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.
Showing 1–10 of 57
Challenge
…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.
Challenge
…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
…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.
Challenge
…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.
Article Python Fundamentals
…(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…
Challenge
…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().
Challenge
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.
Challenge
…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…
Article Mini projects
…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…
Article Mini projects
…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()…