Challenge
Legacy script
A 70-line engine report repeats the same twelve lines for each engine. Restructure it into parse_feed() and summary_line() with the output unchanged to the character, then add assert tests that would…
10 results
Challenge
A 70-line engine report repeats the same twelve lines for each engine. Restructure it into parse_feed() and summary_line() with the output unchanged to the character, then add assert tests that would…
Challenge
The telemetry pipeline is now split into parse_row() and check_limits(). Write assert tests for both, good rows, rejected rows and readings right at a limit, so that each of three planted bugs makes…
Challenge
Simulate 100 sensor readings, each with a 5% chance of a glitch, and seed random with 42 so the count is the same on every run and a test can check it exactly, then pick a kind for each glitch with…
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
Write assert checks for the fixed add_sample() that would have caught the shared default list, then add checks that a log passed in is still the one that gets the sample, so a "fix" that breaks that…
Challenge
Write assert checks for mean(): an ordinary list and a list with one value first, then the edge cases, an empty list that should give None and lists with negative values, so broken copies of the…
Challenge
Write assert checks for alert_level(): one temperature for each level first, then the values exactly on each threshold and just below them, so a > written instead of >= can't slip through.
Challenge
Write assert checks for parse_line() from "Parser function": the whole record for a good line first, then None for a blank line, a comment and a line with a missing field, so a broken parser can't…
Article Mini projects
…Exception as e: return False, f"Verification error: {e}" Testing the Secure Dispenser # TEST SCRIPT - Run this to see it in action! if __name__ == "__main__": print("=== TESTING SECURE MEDICATION…
Article Python Fundamentals
…If a branch isn't executing, print the values you're testing: print("fuel:", fuel_percent, "system:", system_check_passed) Or use assertions in development: assert isinstance(fuel_percent, (int…