Results for “debugging”

Showing 11–20 of 30

  1. 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…

    Fix the code Medium 3 stages functions lists mutation return
  2. Challenge

    Prints instead of returns

    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…

    Fix the code Easy 3 stages functions return print None
  3. Challenge

    Silent branch

    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…

    Fix the code Easy 3 stages functions return None branches
  4. Challenge

    Missing field

    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…

    Fix the code Easy 3 stages dictionaries KeyError get default values
  5. Challenge

    Never-ending wait

    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…

    Fix the code Easy 3 stages while loop infinite loop counter and
  6. Challenge

    One orbit short

    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.

    Fix the code Easy 3 stages for loop range off-by-one step
  7. Challenge

    Backup that isn't

    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…

    Fix the code Medium 3 stages lists copy references is
  8. Challenge

    Missing index

    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.

    Fix the code Easy 3 stages lists indexing IndexError len
  9. Challenge

    sort() returns None

    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.

    Fix the code Easy 3 stages lists sort None in place
  10. Challenge

    Assignment in a condition

    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.

    Fix the code Easy 3 stages if else == SyntaxError