Results for “type conversion”

8 results

  1. Challenge

    input() returns text

    …out the crew after the next docking. Whatever number you type, it crashes. Predict what happens, find out why input() is behind it, fix it, then write a packing tool that reads two numbers. Predict…

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

    Readings that won't add

    …are written. Investigate and modify Investigate. Store the type of the readings in reading_type : int , float , str or bool . Modify. The readings arrive as text, so leave the two lines that set them…

    Fix the code Easy 3 stages type conversion int float str
  3. Challenge

    Fuel for a burn

    …can last part of a second, like 12.4. When you press Run, type the number in the console. When you check, the tests type it for you. What the burn leaves The flight director also wants to know what…

    Write the code Easy 2 stages input float type conversion multiplication
  4. Challenge

    Round or cut?

    int() cuts the decimals off, round() rounds, and round(2.5) gives 2. Predict the difference, investigate Python's rounding rule, then round a fuel reading two ways.

    Write the code Medium 3 stages int round rounding type conversion
  5. Challenge

    Safe number input

    The burn length is typed in by hand, and a typo stops the program with a ValueError. Catch it with try and except, keep asking until the input is a number, then also turn away zero and negative…

    Write the code Easy 2 stages errors try except ValueError