[Tutor] How to correct decimal addition.
Leon S
imtherealleon at gmail.com
Fri Jan 24 18:57:04 CET 2014
Here is what I'm trying to do, accept a price of gas, but I want to add the
.009 to the price, so that people do not have to type the full amount.
Example, 3.49 /gallon would return 3.499 /gallon.
This is what I have tried and the results of it.
def gas_price(price):
price == raw_input("What is the price of gas?") return price + .09
3.49=> 3.4899999999999998
It reduces the number and then adds many decimal points after.
Thanks for any help, I am sure this is an easy one for someone.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140124/3cf9aca3/attachment.html>
More information about the Tutor
mailing list