Results for “try”

Showing 1–10 of 50

  1. Challenge

    Safe number input

    …a typo 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
  2. Challenge

    Test the error

    …only if fuel_needed(-5) raises 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…

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

    Telemetry pipeline

    …rows the way the file does. Check the sensor first, then try the conversion. Flag the limits After the count, check every valid reading against its sensor's range in LIMITS . Collect each one outside…

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

    Catch what you expect

    …were checked twice and they are working. The code has a try and an except , so it can't crash, but the bug is hiding somewhere inside it. Predict what the program prints, find out what the except is…

    Fix the code Medium 3 stages errors try except ValueError
  5. 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
  6. Article Mini projects

    Calculating Escape Velocity in Python

    …CELESTIAL BODY DATA") name = input("Name: ") while True: try: mass_str = input("Mass in kg (e.g. 5.972e24): ") mass = float(mass_str) if mass <= 0: print("Mass must be positive!") continue break…

  7. Article Mini projects

    Managing Astronaut Medical Data with Python

    …"All fields are required!") return try: astronaut_id = int(astronaut_id) heart_rate = int(heart_rate) weight = float(weight) except ValueError: messagebox.showerror("Error", "Invalid input types!")…

  8. Article Mini projects

    Medical dispenser - Don’t trust the user

    …event log""" if not self.log_file.exists(): return [] try: with open(self.log_file, 'r') as f: events = json.load(f) # Verify chain integrity for i, event in enumerate(events): # Reconstruct the…

  9. Challenge

    Command parser

    …raises ValueError with the reason for anything else. Then try every command and print OK and the result, or REJECTED , the command in quotes and the reason: OK ('burn', 12.5) OK ('burn', 3.0) OK…

    Write the code Medium 2 stages project parsing strings split