Challenge
Catch what you expect
A bare except: reports every fuel reading as bad, because it also catches a NameError from a typo. Predict the last line, find the hidden error, catch only ValueError and fix the typo, then write a…
Showing 1–10 of 15
Challenge
A bare except: reports every fuel reading as bad, because it also catches a NameError from a typo. Predict the last line, find the hidden error, catch only ValueError and fix the typo, then write a…
Challenge
…stops the program with a ValueError. Catch it with try and except, keep asking until the input is a number, then also turn away zero and negative lengths.
Challenge
…ValueError : call it in try , set a variable to True in except ValueError: , and assert it after. Then print: All checks passed Leave the function as it is. The hidden tests swap it for a version that…
Challenge
…09:30:15 CABIN: 101.2 kPa Parsed: 4, skipped: 3 Use except ValueError as error: ; inside an f-string, {error} shows the message.
Challenge
A small but complete data pipeline: read the telemetry CSV, reject rows with unknown sensors or broken values and say why, flag readings outside each sensor's limits, and save a JSON summary for the…
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…
Article Mini projects
…verification failed at 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…
Article Mini projects
…heart_rate = int(heart_rate) weight = float(weight) except ValueError: messagebox.showerror("Error", "Invalid input types!") return conn = sqlite3.connect('space_station.db') cursor = conn.cursor()…
Article Mini projects
…mass <= 0: print("Mass must be positive!") continue break except ValueError: print("Invalid value! Try again.") while True: try: radius_str = input("Radius in km: ") radius = float(radius_str) * 1000…
Challenge
…Mask the code Replace every character of the access code except the last four with * , then print it: Access code: **********77AB You need as many stars as there are characters before the last four…