Results for “python loops”

Showing 11–20 of 36

  1. Challenge

    Skip blanks and comments

    …CABIN: 101.2 kPa 09:30:10 ENG-2: 415.0 C At the top of the loop, strip the line, then continue when it's empty or starts with # . Stripping first matters: one comment is indented, and a line can hold…

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

    Check every reading

    Extend the OK/WARN/CRITICAL check from Alert level so a for loop runs it over every temperature in a list, then count the WARN and CRITICAL readings for a summary line.

    Write the code Easy 2 stages for loop lists if elif
  3. Challenge

    Parse the whole feed

    …line, and a parser has to handle every line the same way. Loop over the lines, split each one, and print what the flight controllers need. Line by line Go through the feed line by line, split each…

    Write the code Easy 2 stages for loop splitlines split unpacking
  4. Challenge

    Filter the log

    …ERROR Fuel valve 2 still closed Start with alerts = [] , loop over the log, and append() each line that contains "] WARN" or "] ERROR" . The log itself must stay complete. A minimum level Make the…

    Write the code Medium 2 stages for loop lists append filtering
  5. Challenge

    Retry the uplink

    …a dead link doesn't block everything else. Write the retry loop against a simulator that plays back the radio's replies, then space the attempts out. Up to three tries Try up to MAX_ATTEMPTS times…

    Write the code Medium 2 stages for loop range break retry
  6. Challenge

    Numbered checklist

    …gives pairs of a number and an item. Unpack them in the loop: for number, item in enumerate(checklist, start=1): . Done or not yet The crew has done the first two items. Add completed = 2 under the…

    Write the code Easy 2 stages for loop enumerate start lists
  7. Challenge

    Launch counter crash

    …burn_kg) , which returns the fuel left, and use it in a loop over the planned burns, without global . Print: Burn of 180.0 kg, 1020.0 kg left Burn of 45.5 kg, 974.5 kg left Burn of 310.0 kg, 664.5 kg…

    Fix the code Medium 3 stages functions scope UnboundLocalError global
  8. Challenge

    Safe number input

    The burn length is typed in by hand, and 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…

    Write the code Easy 2 stages errors try except ValueError