Challenge
Float surprise
Predict 0.1 + 0.2, see the 0.30000000000000004 that every programmer meets once, then round it for display the way fuel gauges and dashboards do.
Showing 1–10 of 48
Challenge
Predict 0.1 + 0.2, see the 0.30000000000000004 that every programmer meets once, then round it for display the way fuel gauges and dashboards do.
Challenge
…why and fix it with int(), then add decimal readings with float().
Challenge
…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.
Example
Changing data types using int(), float() and str() functions. Converting between types.
Challenge
An operator types 42,5 and float() crashes with a ValueError. Predict it, find out why, accept both commas and dots with replace(), then read pressures written like 1 013,25.
Example
…recognizes different data types automatically. Learn int, float, str and bool.
Quiz
…Python type conversion and input(): 15 questions on int(), float(), str(), bool() and reading numbers from the user.
Quiz
…beginner quiz on Python data types: 15 questions on int, float, str, bool, None, lists, tuples, dictionaries and sets, with instant answers.
Challenge
…Every value has a type: int for whole numbers, float for decimals, str for text and bool for True / False . Replace each ... with the type of that value, for example crew_type = int . You can check…
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…