Write a unit conversion program that asks the user to identify the unit from which they want to convert and the unit to which they want to convert. Legal units are inches, feet, miles, millimetres, centimetres, meters, and kilometres.

Convert from? Inches
Convert to? Millimetres
Value? 10
10 in = 254 mm

can anybody help me with this program i would be grateful
thanks in advance

8 Years
Discussion Span
Last Post by jlm699

can anybody help me with this program i would be grateful

Sure, but the answer depends on which version of Python you're using.

You'll be using input() (Python 3.X) or raw_input() (Python 2.X) to prompt the user for input.

You'll also want to make sure you're restricting the user's input to only the "allowed" units. You can use a list for this and the logic will basically be, if desired unit not in list; ignore (or warn user, then print out his options so he knows what he's allowed to use)

The rest is simple multiplication. You can look up conversion rates on Google (type for example "1 mm to inch" and search - results in 1 millimeter = 0.0393700787 inch).

Hope that helps

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.