Challenge
Log to a file
…[T+00:12:05] WARN Battery 3 temperature high [T+00:14:47] ERROR Fuel valve 2 not responding The hidden tests also open mission.log and check what is in it. Append without wiping Opening with "w" again…
Showing 21–30 of 55
Challenge
…[T+00:12:05] WARN Battery 3 temperature high [T+00:14:47] ERROR Fuel valve 2 not responding The hidden tests also open mission.log and check what is in it. Append without wiping Opening with "w" again…
Challenge
…then add the round trip without doubling a rounding error.
Challenge
…is not valid JSON is one problem, not valid JSON: and the error's msg ; JSON that is not an object, such as a list, is one problem too. In both cases the config is a copy of the defaults. Only…
Challenge
…counts[level] += 1 . The output stays as it was: DEBUG: 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()…
Article Mini projects
…event {i}") return events except Exception as e: print(f"Error loading log: {e}") return [] def _save_log(self): """Persist event log to disk""" with open(self.log_file, 'w') as f…
Challenge
…passed: [T+00:12:05] INFO Engines nominal [T+00:14:47] ERROR Fuel valve 2 not responding valve=2 pressure_kpa=310 Add **fields after msg . Inside, fields is a dict: build the line, then loop over…
Challenge
…The function is now used for a whole orbit's entries, and ERROR is five letters long, so its messages start one column later than the others. Change only the function so the level is padded to five…
Challenge
…are typed, reject everything else clearly, then make the error messages helpful. Three commands Ask for a command with input() . Accept start , stop and status in any case and with spaces around them…
Quiz
Free beginner quiz on Python lists: 15 questions on indexing, slicing, append, insert, pop, remove, sorting and copying, with instant answers.
Challenge
Write parse_command(), which turns typed commands 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…