Challenge
sort() returns None
crew = crew.sort() leaves the roster as None. Predict it, find out what sort() really gives back, fix it by sorting in place, then sort readings from highest to lowest and keep the top three.
Showing 1–10 of 27
Challenge
crew = crew.sort() leaves the roster as None. Predict it, find out what sort() really gives back, fix it by sorting in place, then sort readings from highest to lowest and keep the top three.
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
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.
Example
Methods sort() and reverse() for ordering list elements.
Quiz
…on indexing, slicing, append, insert, pop, remove, sorting and copying, with instant answers.
Challenge
…schedule from JSON, keep the launches still to come, sort them by their window and print a digest line for each with the time left and any hold, then switch the digest to the live clock.
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
…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…
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.