954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

python unit conversion

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

s.praneeth
Newbie Poster
5 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

What do you have so far?

gerard4143
Nearly a Posting Maven
2,272 posts since Jan 2008
Reputation Points: 512
Solved Threads: 387
 

i am nowhere i have just posted

s.praneeth
Newbie Poster
5 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

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

s.praneeth
Newbie Poster
5 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

You should read the member rules

gerard4143
Nearly a Posting Maven
2,272 posts since Jan 2008
Reputation Points: 512
Solved Threads: 387
 
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

jlm699
Veteran Poster
1,112 posts since Jul 2008
Reputation Points: 355
Solved Threads: 292
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: