如何在python中显示浮点数?

时间:2014-05-22 20:23:48

标签: python

我到处搜索和搜索,我找不到在python 2.7.6中使用float类型的具体方法我需要制作一个程序来计算在给定时间内产生的利息收入,这就是我到目前为止:

interest = input("What is your interest rate?")
bank = input("How much money are you starting with?")
time = input ("How long will the money sit(in years. dont enter anything less than a year, as it wont count anyway)?")

interest = interest / 100

total = bank * interest
total = total * time

print ("Starting funds     : $"+str(bank))
print ("Time sat in months : "+str(time))
print ("Interest rate      : %"+str(interest))
print ("\n\n")
print ("Total money now    : $"+str(total))

print ("Press any key to continue...")

这是输出:

What is your interest rate?2
How much money are you starting with?1000
How long will the money sit(in years. dont enter anything less than a year, as it wont count anyway)?2
Starting funds     : $1000
Time sat in months : 2
Interest rate      : %0



Total money now    : $0
Press any key to continue...

注意利率如何回报0?这导致总数也为0,所以我不知道如果我做错了什么,或者我只需要使用浮点数。 (我很抱歉,如果我的格式是垃圾,我已经多次试图解决这个程序的问题)

0 个答案:

没有答案