Challenge
Test the error
Write a check that passes only when fuel_needed(-5) raises ValueError, so a version that returns a value or raises the wrong error fails it, then pin down the message and the lengths that must still…
Showing 1–10 of 16
Challenge
Write a check that passes only when fuel_needed(-5) raises ValueError, so a version that returns a value or raises the wrong error fails it, then pin down the message and the lengths that must still…
Challenge
…such as burn 12.5 or set mode safe into tuples and raises ValueError with a reason for anything malformed, then run a whole batch of commands and report each one.
Challenge
…negative fuel for a negative burn length. Make it raise ValueError with a message that shows the bad value, then raise TypeError, checked first, when the length isn't a number at all.
Challenge
…and refuses unknown units or missing pairs with a clear ValueError, then extend the table with offsets for temperatures.
Challenge
…Predict the last line, find the hidden error, catch only ValueError and fix the typo, then write a parser that lets other errors through.
Challenge
…is typed in by hand, and a typo stops the program with a ValueError. Catch it with try and except, keep asking until the input is a number, then also turn away zero and negative lengths.
Challenge
…variables and print a cargo manifest line, then fix the ValueError when the manifest adds a fourth field.
Challenge
…value as a number, and a row from an unknown sensor raises ValueError . Then print: All checks passed Leave the functions as they are. The hidden tests plant two bugs in parse_row() : one keeps the…
Challenge
…it skipped. Skip and count The program stops at ERR with a ValueError . Put the conversion in try ; when it fails, add 1 to a new counter, skipped , and go on to the next line. At the end, report all…
Challenge
An operator types 42,5 and float() crashes with a ValueError. Predict it, find out why, accept both commas and dots with replace(), then read pressures written like 1 013,25.