Results for “len”

Showing 11–20 of 45

  1. Challenge

    Summary function

    …'mean': 419.5} Build the dict in the return line, with len() , min() , max() and sum() / len() . No data, and a rounded mean The second pass had no data, and min([]) stops with a ValueError . For an…

    Write the code Medium 2 stages functions return dictionaries min
  2. Challenge

    Shift rota

    …shifts: 0 Count the shifts in slot as you go: crew[slot % len(crew)] wraps round to the first person after the last. {name:<10} pads the names into columns. Days off, fairly Now some of the crew have…

    Write the code Hard 2 stages project scheduling lists tuples
  3. Challenge

    Unit mix-up

    …convert leg 2 before it's added. It must print: Trajectory length: 386,294 km Make: Landing in metres A lander's altitude comes from its radar in metres, but the backup sensor reports the descent rate…

    Fix the code Easy 3 stages units conversion constants debugging
  4. Challenge

    Any number of values

    …419.5 Inside the function, values is a tuple, so sum() and len() work on it. In the second call, average(*readings) passes the five readings as five separate arguments. An option after the values Add…

    Write the code Easy 2 stages functions *args unpacking keyword-only arguments
  5. Challenge

    Survive bad lines

    …a line with too few fields raises ValueError too. Drop the length check and let one try cover both the unpacking and the conversion. For each line it skips, print the line and the error's message…

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

    Print the manifest

    …kg CG-0046 | Tablet computers | 3.4 kg CG-0047 | Rice and lentils | 25.0 kg Loop over cargo ; each record is a dict, so record["id"] , record["item"] and record["mass_kg"] give its fields. The total…

    Write the code Easy 2 stages dictionaries lists of dicts for loop formatting
  7. Challenge

    Decimal comma

    …an operator at a European ground station types the burn length the way it is written in Poland and much of Europe, 42,5 , and the program stops. Predict what happens, find out why, make the calculator…

    Fix the code Easy 3 stages strings replace float ValueError
  8. 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
  9. Challenge

    Edge cases

    Write assert checks for mean(): an ordinary list and a list with one value first, then the edge cases, an empty list that should give None and lists with negative values, so broken copies of the…

    Write the code Medium 2 stages testing assert edge cases None