Results for “except”

10 results

  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. 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
  8. Challenge

    Command parser

    Write parse_command(), which turns typed commands such as burn 12.5 or set mode safe into tuples and raises ValueError with a reason for anything malformed, then run a whole batch of commands and…

    Write the code Medium 2 stages project parsing strings split
  9. Challenge

    Clear error messages

    fuel_needed() quietly returns negative fuel for a negative burn length. Make it raise ValueError with a message that shows the bad value, then raise TypeError, checked first, when the length isn't a…

    Write the code Medium 2 stages errors raise ValueError TypeError
  10. Challenge

    Unit converter

    Write convert(), which looks a unit pair up in a table of factors, works the other way round by dividing, and refuses unknown units or missing pairs with a clear ValueError, then extend the table with…

    Write the code Medium 2 stages project dictionaries tuples as keys functions