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

Recommended Answers

All 5 Replies

What do you have so far?

i am nowhere i have just posted

could u help me with the program plsss i would be thankful

You should read the member rules

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.