0

Hi so I just got into python a few days ago and I was working on this assignment from a book. I am supposed to find the property tax and assessment tax on a piece of land.

def assessment_value(property_value):
    assessed_value = property_value * 0.60
    print "Your assessed property value is $%d." % assessed_value
    property_tax(assessed_value)

def property_tax(assessed_value):
    tax = (assessed_value / 100.0) * 0.64
    print "Your property tax is $%d." % tax

def main():
    property_value = float(raw_input("Please enter the value of your property. "))
    assessment_value(property_value)

main()

When everything runs using 10000 as the property value the result I get is 38 instead of 38.4. What confuses me is if I do float(60) * 0.64 it returns the value I want which is 38.4. But if I set the value of tax to be 60 it returns 38. Sorry if this is an extremely simple question as I said I am new to python and I have no one to help me.

4

2 回答 2

2

您正在使用该值作为%d字符串中的整数。您将需要使用%f. 请参阅字符串格式化操作的文档

于 2012-12-26T19:22:25.440 回答
1

这是因为你使用%d. 对于浮动,您可以使用%f%.2f

于 2012-12-26T19:23:06.483 回答