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…
Showing 1–10 of 27
Challenge
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…
Challenge
…live roster too. Predict it, prove it with is, fix it with copy(), then plan a crew swap on a real copy.
Challenge
…The same list has to be shown both ways. Make a sorted copy for the report and leave the original alone, then make the sort cope with names that start with a small letter. A copy for the report Print…
Challenge
Build a user's settings by copying the defaults and laying their own values on top with update(), so any setting they haven't changed falls back, then warn about unknown keys instead of saving them.
Challenge
Load the downlink module's JSON settings over a copy of the defaults, check each value's type and range and report every problem in one go, then wrap it all in a load_config() that never crashes, even…
Challenge
Print each capsule event once, keeping the first copy, by checking every ID against a set of IDs already seen, then report which IDs came in more than once.
Article Mini projects
…# Reconstruct the message that was signed event_copy = event.copy() stored_hmac = event_copy.pop('hmac') event_string = json.dumps(event_copy, sort_keys=True) expected_hmac =…
Quiz
…slicing, append, insert, pop, remove, sorting and copying, with instant answers.
Challenge
…with the value 63. Investigate and modify Investigate. Copy the condition Python checks first into checked_first , as text. Then think about any value at all: could it ever reach the CRITICAL branch…
Challenge
An oxygen check uses = instead of == and has a line that isn't indented, so Python refuses to run it. Predict what happens, fix both errors one after the other, then write an if/else check yourself.