Challenge
Decimal comma
An operator types 42,5 and float() crashes with a ValueError. Predict it, find out why, accept both commas and dots with replace(), then read pressures written like 1 013,25.
Showing 11–20 of 21
Challenge
An operator types 42,5 and float() crashes with a ValueError. Predict it, find out why, accept both commas and dots with replace(), then read pressures written like 1 013,25.
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
…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 #…
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
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
…mean The second pass had no data, and min([]) stops with a ValueError . For an empty list, return a count of 0 and None for the other three. Round the mean to one decimal place, too. Print both…
Challenge
…The parser from "Parse the whole feed" stops with a ValueError on the first comment line. Skip blank lines and comment lines, so it prints only the readings: 09:30:05 ENG-2: 412.5 C 09:30:05 TANK-1…
Quiz
…text with int() and float() , and which text raises a ValueError Numbers kept as text: joining, comparing and counting digits What int() does to a negative float, and which values bool() turns into…
Challenge
…them. The starter code parses the line and stops with a ValueError , because float("") makes no sense. Check the field before converting it: ENG-2: NO DATA Strip the field first, so a field with only…
Challenge
…their name: LIFE-SUPPORT-4 . The starter code stops with a ValueError , because split("-") cuts at every dash and int("SUPPORT") makes no sense. Split only at the last dash, so it prints: Subsystem…