Challenge
Count warnings
…mission log: how many entries, and how many of them are warnings. A sudden jump in warnings is often the first sign that something is going wrong. Count them, make sure the count can't be fooled, then…
Showing 1–10 of 14
Challenge
…mission log: how many entries, and how many of them are warnings. A sudden jump in warnings is often the first sign that something is going wrong. Count them, make sure the count can't be fooled, then…
Challenge
…for its level: logging.debug() , logging.info() , logging.warning() or logging.error() , and drop the level from the text, since the format adds it. With the level set to INFO , the debug lines…
Challenge
…setting good_text: Config OK: retries = 5, log_level = WARNING broken_text: not valid JSON: Expecting ',' delimiter
Challenge
…find the first ERROR, then rank the subsystems by how many warnings they raised.
Article Mini projects
…or secure key storage secret = os.urandom(32) print("Warning: Using randomly generated secret. Set MEDICATION_DISPENSER_SECRET environment variable for production.") return secret def…
Challenge
fuel_needed() quietly 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…
Example
Multiple conditions with elif. Checking several possibilities in sequence.
Example
Conditional if statement allows executing code only when condition is met.
Example
Simple way to check installed Python version on your system. First step for every programmer.
Challenge
…the three lengths are equal, and if they aren't, print a warning first: Warning: 4 sensors, 3 readings, 4 units ENG-1: 398.0 C ENG-2: 412.5 C TANK-1: 78.3 % len(sensors) == len(readings) == len(units)…