Challenge
Sorted copy
Print the roster A–Z for a report with sorted() while the sign-up order stays exactly as it was, then sort names like de Vries and van Dijk correctly with key=str.lower.
Showing 1–10 of 20
Challenge
Print the roster A–Z for a report with sorted() while the sign-up order stays exactly as it was, then sort names like de Vries and van Dijk correctly with key=str.lower.
Challenge
…datetime, works for the comparison and as the key for sorted() . strftime("%Y-%m-%d %H:%M") formats a datetime. Time left, and holds Add the time left to each launch, as days, hours and minutes, and…
Challenge
Sort launches by date with sorted() and a small function that returns each launch's date, then sort the cargo manifest heaviest first with a key function and reverse=True.
Challenge
…added since yesterday and which were removed, each list sorted: Added: CG-0047, CG-0048 Removed: CG-0043, CG-0045 set(today) - set(yesterday) is what today has that yesterday didn't. A set has no…
Quiz
…extend() Removing items with pop() and remove() sort() vs sorted() , min() , max() and sum() Copying a list, and lists inside lists How it works 15 questions: 11 with one correct answer, 4 where you…
Challenge
…from an empty dict and use counts.get(level, 0) + 1 . sorted(counts) gives the levels A to Z.
Challenge
…49.8 kg (41%) crew: 3.4 kg (3%) spares: 2.4 kg (2%) sorted(totals, key=totals.get, reverse=True) gives the categories ordered by their totals. sum(totals.values()) is the whole load.
Challenge
…before you check. Modify. Fix the sort so the roster is sorted and kept. It must print: Roster: ['Kowalska', 'Lindqvist', 'Okafor', 'Tanaka'] Make: Top three readings Sort the engine readings from…
Challenge
…every contact window longer than 8 minutes into one list, sorted by time, then find the longest stretch with no station in contact, counting overlapping passes only once.
Challenge
…2 ERROR: 1 INFO: 4 WARN: 3 Most common first Replace the sorted listing with one from the most common level down, using counts.most_common() , under a heading: By frequency: INFO: 4 WARN: 3 DEBUG: 2…