Challenge
Clear error messages
…returns negative fuel for a negative burn length. Make it raise ValueError with a message that shows the bad value, then raise TypeError, checked first, when the length isn't a number at all.
Showing 1–10 of 24
Challenge
…returns negative fuel for a negative burn length. Make it raise ValueError with a message that shows the bad value, then raise TypeError, checked first, when the length isn't a number at all.
Challenge
…such as burn 12.5 or set mode safe into tuples and raises ValueError with a reason for anything malformed, then run a whole batch of commands and report each one.
Challenge
Write a check that passes only when fuel_needed(-5) raises ValueError, so a version that returns a value or raises the wrong error fails it, then pin down the message and the lengths that must still…
Challenge
…round, divide; for the same unit twice, return the value. Raise ValueError for a unit the table doesn't know, unknown unit: ... , or for two known units with no factor between them. Then run the…
Challenge
The monitoring system raises the same alert over and over. Group repeats of an alert that come within 60 seconds of the first into one line with a count, in the order they first appeared, then add the…
Challenge
…the value as a number, and a row from an unknown sensor raises ValueError . Then print: All checks passed Leave the functions as they are. The hidden tests plant two bugs in parse_row() : one keeps…
Challenge
…ERROR, then rank the subsystems by how many warnings they raised.
Article Mini projects
…if expected_hmac != stored_hmac: raise ValueError(f"HMAC verification failed at event {i}") return events except Exception as e: print(f"Error loading log: {e}") return [] def _save_log(self)…
Challenge
The pre-burn check decides whether the orbit-raising burn goes ahead. Someone changed it last night in a hurry, and now it doesn't even start. The burn window opens in an hour, and you are the…
Example
Adding and removing elements from a set. Basic set operations.