Results for “if”

Showing 31–40 of 63

  1. Challenge

    Silent branch

    status_light() returns None for Scrub because that branch sets a variable but never returns it. Predict the last line, find which statuses give None, make every path return, then write a function…

    Fix the code Easy 3 stages functions return None branches
  2. 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
  3. 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
  4. Challenge

    Manifest validator

    Write problems(item), which lists everything wrong with one cargo item: missing fields, a mass that isn't a number, is 0 or is over the limit. Print a pass or fail line per item, then catch duplicate…

    Write the code Medium 2 stages project validation dictionaries functions
  5. Challenge

    Survive bad lines

    Extend the feed parser from "Skip blanks and comments": a faulty sensor sends ERR and float() stops the program. Skip lines that fail to convert and count them, then let one try cover short lines too…

    Write the code Medium 2 stages errors try except ValueError
  6. Challenge

    Test the alert levels

    Write assert checks for alert_level(): one temperature for each level first, then the values exactly on each threshold and just below them, so a > written instead of >= can't slip through.

    Write the code Medium 2 stages testing assert functions boundaries
  7. Challenge

    Test the parser

    Write assert checks for parse_line() from "Parser function": the whole record for a good line first, then None for a blank line, a comment and a line with a missing field, so a broken parser can't…

    Write the code Medium 2 stages testing assert parsing None
  8. Challenge

    Validate a cargo record

    Write validate_cargo(item), which returns a list of everything wrong with a cargo record: missing fields and a negative mass, then a cargo ID that doesn't match the CG- and four digits format. An…

    Write the code Medium 2 stages functions return lists validation
  9. Challenge

    Launch schedule digest

    Parse the launch schedule from JSON, keep the launches still to come, sort them by their window and print a digest line for each with the time left and any hold, then switch the digest to the live…

    Write the code Medium 3 stages project json datetime timedelta
  10. 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