Results for “python input”

Showing 1–10 of 21

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

    Safe number input

    …Catch it with try and except, keep asking until the input is a number, then also turn away zero and negative lengths.

    Write the code Easy 2 stages errors try except ValueError
  3. Challenge

    Fuel for a burn

    Ask for an engine burn length with input(), turn it into a number with float() and work out the propellant it uses, then read the tank level too and show what the burn leaves.

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

    Validate a command

    Read a console command with input(), accept start, stop and status in any case with an if/elif chain, print Unknown command for anything else, then handle empty input and show what was typed.

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

    Downlink time

    Read a file size in MB and a link speed in Mbit/s with input(), work out the transfer time without forgetting the 8 bits in a byte, show it in minutes and seconds, then count the ground station…

    Write the code Medium 3 stages input float bits and bytes round
  6. Challenge

    Normalise a command

    Turn " Launch " into launch with strip() and lower(), check it against the command list, then accept underscores and dashes too, so commands match however operators type them.

    Write the code Easy 3 stages strings strip lower replace
  7. Article Mini projects

    Calculating Escape Velocity in Python

    …to do: We know the physics formula: v = √(2GM/r) We need input data: planet's mass and radius We must perform mathematical calculations We'll display the result in a readable format Sounds simple?…

  8. Article Mini projects

    Converting Temperatures in Python

    …of value retrieval or conversion. Therefore, using the input() function, we can get the menu choice and display the next command. choice = int(input("Enter 1 or 2 and press enter: ")) We assign the…