Results for “debugging”

Showing 21–30 of 37

  1. 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
  2. Challenge

    Flag from config text

    A config file says dry_run is False, yet bool("False") turns it into True and the engine simulates instead of firing. Predict it, find out why, compare the text instead, then read yes/no settings…

    Fix the code Easy 3 stages bool if else config
  3. Challenge

    Unreachable branch

    A vibration check reports WARN for a reading of 63 because its elif conditions are in the wrong order, so CRITICAL can never run. Predict it, find the dead branch, fix the order, then write a…

    Fix the code Easy 3 stages if elif order of conditions debugging
  4. Challenge

    Off-by-one slice

    A slice meant to take the number from the container tag CG-0042 gives -004. Predict it, work out where indexes start and where a slice ends, fix it, then slice a sample label yourself.

    Fix the code Easy 3 stages strings slicing indexing off-by-one
  5. Challenge

    Strings don't change

    code[0] = "X" stops with a TypeError, because Python strings can't be changed. Predict the crash, find out what methods and slices really give, build a new string instead, then swap a letter in the…

    Fix the code Easy 3 stages strings immutability slicing TypeError
  6. Challenge

    input() returns text

    A crew count read with input() crashes when 1 is added to it. Predict the crash, find out what input() really returns, fix it with int(), then write a packing tool that reads two numbers.

    Fix the code Easy 3 stages input int TypeError type conversion
  7. Challenge

    Unit mix-up

    A trajectory total adds a leg in miles to legs in kilometres. Predict the total, find the leg that doesn't fit, convert it with a named constant, then convert a lander's feet per second to metres.

    Fix the code Easy 3 stages units conversion constants debugging
  8. Challenge

    Wrong average

    An average of three hull temperatures comes out at 47 °C when every sensor reads about 21. Predict it, find where the brackets are missing, fix it, then work out an average speed.

    Fix the code Easy 3 stages order of operations brackets average debugging
  9. Challenge

    Readings that won't add

    Two sensor readings add up to 12080 instead of 200 because they arrived as text. Predict it, find out why and fix it with int(), then add decimal readings with float().

    Fix the code Easy 3 stages type conversion int float str