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…
Showing 21–30 of 68
Challenge
…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…
Challenge
…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…
Challenge
…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…
Challenge
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…
Challenge
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…
Example
Lists store multiple elements in a specific order. Basics of working with lists.
Example
How to create text and join it in Python. Basics of working with strings.
Challenge
…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…
Article Python Fundamentals
…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…
Challenge
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…