Challenge
Unit converter
Write convert(), which looks a unit pair up in a table of factors, works the other way round by dividing, and refuses unknown units or missing pairs with a clear ValueError, then extend the table with…
Showing 51–58 of 58
Challenge
Write convert(), which looks a unit pair up in a table of factors, works the other way round by dividing, and refuses unknown units or missing pairs with a clear ValueError, then extend the table with…
Challenge
Write problems(item), which lists everything wrong with one cargo item: missing fields, a mass that isn't a number, is 0 or is over the limit. Print a pass or fail line per item, then catch duplicate…
Challenge
Write validate_cargo(item), which returns a list of everything wrong with a cargo record: missing fields and a negative mass, then a cargo ID that doesn't match the CG- and four digits format. An…
Challenge
…new_record(sensor, value, flags=None) , which returns a dict with a fresh flags list whenever none is given. The program flags the first record, and the second must stay clean: {'sensor': 'ENG-2'…
Challenge
The telemetry pipeline is now split into parse_row() and check_limits(). Write assert tests for both, good rows, rejected rows and readings right at a limit, so that each of three planted bugs makes…
Example
When to use tuples instead of lists? Comparison of properties and applications.
Challenge
…right after the check that found it, count the kinds in a dict called by_kind , and print them sorted after the total: Glitches in 100 readings: 5 DROPOUT: 3 SPIKE: 2 Call random.choice() only for…
Example
Sets store only unique elements without a specific order.