Tuesday 10 September 2013

Python - Adding a decimal

Python - Adding a decimal

Lets say I have the following function that converts ounces to lbs & oz
def oz2lboz(oz):
oz, lbs = oz - int(oz), int(oz)
l = lbs * 0.062500
o = oz
print "(%d,%d)" % (l,o)
Right now, if i was to compute oz2lboz(16), it would give me
(1,0)
However, I need it to give me,
(1,0.0)
How would i go about doing that?

No comments:

Post a Comment