Results for “len”

Showing 21–30 of 68

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. Challenge

    Sort by a field

    …meals 31.3 kg CO2 scrubber cartridges 25.0 kg Rice and lentils 18.5 kg Water filter cartridges 3.4 kg Tablet computers 2.4 kg Spare cabin fan Write mass(item) , which returns item["mass_kg"] , and…

    Write the code Easy 2 stages functions sorted key reverse
  7. Article Python Fundamentals

    Numbers and Basic Math Operations in Python

    …readings. Integers (int) Integers in Python can be of any length, limited only by your computer's memory. This is particularly useful when dealing with astronomical distances or spacecraft sensor…

  8. Challenge

    Flight software review

    A 40-line pre-burn check has five bugs: a syntax error, a type error, a wrong key, an index out of range and a reversed decision. Read each error to fix the four that crash, then find the one that…

    Fix the code Hard 2 stages project debugging SyntaxError TypeError