Results for “variable”

Showing 1–10 of 21

  1. Challenge

    Names that explain

    …a quick calculation for the cargo module and called the variables a , b , x2 and tmp . The program works, but nobody, including its author a month from now, can tell what it calculates without working…

    Fix the code Easy 3 stages variable names refactoring readability clean code
  2. Challenge

    Mission config

    Predict, investigate and extend a mission config held in variables: text, whole numbers, decimals and True/False. A PRIMM challenge on Python data types.

    Write the code Easy 3 stages variables data types int float
  3. Challenge

    Shadowed fuel

    …assigns to fuel_kg inside the function, creating a local variable and leaving the global fuel unchanged. Predict the last line, compare both values, fix it by returning the total, then write a…

    Fix the code Medium 3 stages functions scope local variables global variables
  4. Challenge

    Safe mode

    …using or, then name the rule that fired with boolean variables and an if/elif chain.

    Write the code Medium 2 stages if elif or and
  5. Challenge

    Manifest line

    Unpack an (id, item, mass_kg) tuple into three named variables and print a cargo manifest line, then fix the ValueError when the manifest adds a fourth field.

    Write the code Easy 2 stages tuples unpacking ValueError formatting
  6. Challenge

    Alert level

    …check the exact boundaries, then store the level in a variable for a status line.

    Write the code Easy 2 stages if elif else comparisons
  7. Challenge

    Magic numbers

    Turn the bare 9.81 and 1000 in a weight report into named constants without changing the output, then write a Mars version with constants from the start.

    Fix the code Easy 3 stages constants refactoring variables clean code
  8. 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
  9. Challenge

    Landing site

    …landing site as a (lat, lon) tuple, unpack it into two variables in one line and print both to four decimals, then show it the way maps do, with N, S, E and W.

    Write the code Easy 2 stages tuples unpacking formatting coordinates