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.
Showing 1–10 of 21
Challenge
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.
Challenge
…Catch it with try and except, keep asking until the input is a number, then also turn away zero and negative lengths.
Quiz
Free beginner quiz on Python type conversion and input(): 15 questions on int(), float(), str(), bool() and reading numbers from the user.
Challenge
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.
Challenge
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.
Challenge
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…
Challenge
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.
Article Mini projects
…you through each step, from setting up planet data to user input and weight calculation. Ideal for future space cadets at Gdyni
Article Mini projects
…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?…
Challenge
…returning a new list, then write a filter that leaves its input alone.