I am trying to write some variables that convert inches and pounds to centimeters and kilos. I’m trying to work out the math in Python and having some trouble.
After struggling a while, I managed to do this in Python:
inches = 19
centimeters = inches * 2.54
print "%r inches equals %r centimeters." % (inches, centimeters)
pounds = 180
kilos = pounds /2.2
print "%r pounds equals %r kilos." % (pounds, kilos)
While the inch to cm calculation works great, I get an incorrect result on pounds to kilos (e.g. wolframalpha says it should be 81.65kg.)
What am I doing wrong and how can I fix this in order to get the right result?
Thanks!
So your code has to be:
And you get the correct result.