Results for “for loop”

Showing 21–30 of 36

  1. Challenge

    Legacy script

    A 70-line engine report repeats the same twelve lines for each engine. Restructure it into parse_feed() and summary_line() with the output unchanged to the character, then add assert tests that would…

    Fix the code Hard 2 stages project refactoring functions testing
  2. Challenge

    Counter

    …pattern comes up so often that Python has a whole class for it. Swap it in, then use the one thing a plain dict can't do for you: sort by count. Counter() Import Counter from collections , start with…

    Fix the code Easy 2 stages collections Counter most_common dictionaries
  3. Challenge

    Manifest validator

    The logistics team typed the manifest for the next supply flight by hand, and the loading crew won't touch a crate until every line checks out. Last time, a typo in a mass sent a 61 kg battery pack to…

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

    Telemetry from CSV

    …read it with csv.DictReader, using the header row for the field names, then find the hottest temperature reading, comparing the values as numbers.

    Write the code Medium 2 stages csv csv.DictReader files open
  5. Challenge

    Extra log fields

    Extend format_log() from "Log formatter function" with **fields, so any extra keyword arguments are added to the line as key=value pairs, then pass whole dicts of fields into it with ** at the call.

    Write the code Medium 2 stages functions **kwargs keyword arguments dictionaries
  6. Challenge

    Survive bad lines

    …let one try cover both the unpacking and the conversion. For each line it skips, print the line and the error's message: 09:30:05 ENG-2: 412.5 C 09:30:05 TANK-1: 78.3 % Skipped…

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

    Extract a function

    Move a 3D distance calculation that is copied for three waypoints into distance_km(a, b), keeping the output exactly the same, then put the waypoints in a dict and find the nearest one with the same…

    Fix the code Easy 2 stages functions refactoring return tuples
  8. 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
  9. Challenge

    Airlock permissions

    …from basic operator training to the commander's approval for opening the outer hatch, and the airlock's control panel checks them before it does anything. Check one action for one crew member, then…

    Write the code Medium 2 stages sets subset difference permissions