Results for “except”

Showing 1–10 of 15

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

    Fix the code Medium 3 stages errors try except ValueError
  2. Challenge

    Safe number input

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

    Write the code Easy 2 stages errors try except ValueError
  3. Challenge

    Test the error

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

    Write the code Medium 2 stages testing assert try except
  4. Challenge

    Survive bad lines

    …09:30:15 CABIN: 101.2 kPa Parsed: 4, skipped: 3 Use except ValueError as error: ; inside an f-string, {error} shows the message.

    Write the code Medium 2 stages errors try except ValueError
  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

    Test the pipeline

    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…

    Write the code Hard 2 stages project testing assert try
  7. Article Mini projects

    Medical dispenser - Don’t trust the user

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

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

  9. Article Mini projects

    Calculating Escape Velocity in Python

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

  10. Challenge

    Redact the access code

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

    Write the code Medium 2 stages strings slicing len replace