Results for “variables”

Showing 1–10 of 21

  1. 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
  2. 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
  3. 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
  4. 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
  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

    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
  7. 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
  8. Challenge

    What arrived?

    …each value to the type it should have, into the new variables named in the comments, then print each new value and its type: altitude_km: 408 <class 'int'> speed_kms: 7.66 <class 'float'> crew: 3…

    Write the code Easy 3 stages type() data types type conversion sensor data
  9. 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