Challenge
Changed the caller's list
add_reading() appends to the list it receives, so the caller's stored readings change too. Predict the first line, prove both names share one list, fix it by returning a new list, then write a filter…
Showing 11–20 of 30
Challenge
add_reading() appends to the list it receives, so the caller's stored readings change too. Predict the first line, prove both names share one list, fix it by returning a new list, then write a filter…
Challenge
to_kelvin() prints its result instead of returning it, so the caller gets None. Predict the last line, find out what the function gives back, fix it with return, then write a conversion function that…
Challenge
status_light() returns None for Scrub because that branch sets a variable but never returns it. Predict the last line, find which statuses give None, make every path return, then write a function…
Challenge
Reading launch["pad"] stops with a KeyError when the API hasn't assigned a pad yet. Predict it, check the keys with in, fix it with get() and a default, then print a list of launches with defaults for…
Challenge
A while loop waits for the antenna signal but never moves on to the next reading, so it never ends. Predict it, find the stuck counter, fix it, then write a wait that gives up when the readings run…
Challenge
A loop over range(1, 10) logs nine orbits of a ten-orbit flight. Predict the last line, find out where range() stops, fix it with ORBITS + 1, then list every third orbit with a range() step.
Challenge
backup = crew gives one list two names, so removing someone from the backup removes them from the live roster too. Predict it, prove it with is, fix it with copy(), then plan a crew swap on a real…
Challenge
readings[5] on a list of five readings stops with an IndexError. Predict it, work out the valid indexes with len(), fix it with [-1], then print the first, middle and last readings for any length.
Challenge
crew = crew.sort() leaves the roster as None. Predict it, find out what sort() really gives back, fix it by sorting in place, then sort readings from highest to lowest and keep the top three.
Challenge
An oxygen check uses = instead of == and has a line that isn't indented, so Python refuses to run it. Predict what happens, fix both errors one after the other, then write an if/else check yourself.