Results for “variables”

Showing 11–20 of 21

  1. Challenge

    Silent branch

    …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 where every path…

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

    Unit mix-up

    …thousands. Investigate and modify Investigate. Find the variable that holds a distance in a different unit and store its name, as text, in odd_one_out . Then convert it: one mile is 1.609344 km. Store…

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

    Legacy script

    …It repeats the same twelve lines for each engine, the variables are called t , m and s , and a fourth engine is being installed next month. Restructure it without changing a single character of what…

    Fix the code Hard 2 stages project refactoring functions testing
  4. Challenge

    Copy-pasted blocks

    …of (name, level) pairs and one loop. Keep the three level variables, which come from telemetry. The output must stay exactly the same: Tank A: 78.3% Tank B: 12.5% LOW Tank C: 46.0% Build tanks =…

    Fix the code Medium 2 stages refactoring for loop tuples lists
  5. Challenge

    Roster changes

    …puts x at index 1, and crew.remove(x) deletes it. Use the variables, not the names. Reassigned After the changes, the newest member, now last in the list, is reassigned to the space station. Take them…

    Write the code Easy 2 stages lists append insert remove
  6. Challenge

    Flag from config text

    …give and store the answers, True or False , in the two variables. Run them to check, and remove any lines you added before you check. Modify. Work dry_run out by comparing the text with "True" , so it…

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

    Test the error

    …fuel_needed(-5) raises ValueError : call it in try , set a variable to True in except ValueError: , and assert it after. Then print: All checks passed Leave the function as it is. The hidden tests…

    Write the code Medium 2 stages testing assert try except
  8. Challenge

    Extract a function

    …once and then pasted for the next two waypoints, with the variable names changed by hand. One wrong name in one copy and the display would lie about one waypoint only. Give the formula a name, call it…

    Fix the code Easy 2 stages functions refactoring return tuples
  9. Challenge

    Validate a command

    …(use start, stop or status) Keep the typed text in one variable and the lower-case version in another. Check for empty text first. For Launch , the second line is printed.

    Write the code Easy 2 stages if elif else input
  10. Challenge

    Status message crash

    …Fix the print line without changing the message or the variable: turn the number into text where you join it, with str() . It must print: Altitude: 408 km Make: Docking status During docking, the…

    Fix the code Easy 3 stages TypeError str type conversion debugging