Results for “ValueError”

Showing 11–20 of 21

  1. 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.

    Fix the code Easy 3 stages strings replace float ValueError
  2. Article Mini projects

    Managing Astronaut Medical Data with Python

    …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()…

  3. Article Mini projects

    Calculating Escape Velocity in Python

    …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 #…

  4. Article Mini projects

    Medical dispenser - Don’t trust the user

    …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)…

  5. Challenge

    Telemetry pipeline

    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…

    Write the code Hard 3 stages project csv json files
  6. Challenge

    Summary function

    …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…

    Write the code Medium 2 stages functions return dictionaries min
  7. Challenge

    Skip blanks and comments

    …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…

    Write the code Medium 2 stages for loop continue strip startswith
  8. Challenge

    Missing reading

    …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…

    Write the code Medium 2 stages if else None is None
  9. Challenge

    Sensor ID parts

    …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…

    Write the code Medium 2 stages strings split rsplit int