Challenge
Assignment in a condition
…what happens, fix both errors one after the other, then write an if/else check yourself.
Showing 11–20 of 95
Challenge
…what happens, fix both errors one after the other, then write an if/else check yourself.
Challenge
…run. Predict it, find the dead branch, fix the order, then write a four-level chain.
Challenge
…out what input() really returns, fix it with int(), then write a packing tool that reads two numbers.
Challenge
…name holds, rename them so the code explains itself, then write a fuel check with good names.
Challenge
Write parse_command(), which turns typed commands 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…
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 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
Write average(*values), which accepts any number of numbers, call it with loose values and with a list unpacked by *, then add a keyword-only decimals option after *values and return None when there…
Challenge
Write assert checks for the fixed add_sample() that would have caught the shared default list, then add checks that a log passed in is still the one that gets the sample, so a "fix" that breaks that…
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…