Reputation: 552
interest = int(float(raw_input("Interest Rate: ")))
monintrate = int(float(( interest / 100.0 ) / 12))
annintrate = int(float(interest / 12))
print "Interest: ",interest
print "Mon Int Rate: ",monintrate
print "Ann Int Rate: ",annintrate
hello, i would like to properly calculate the above variables as decimals but for whatever reason i cant get it work correctly. can someone point me in the right direction?
Below are my results:
Interest: 5
Mon Int Rate: 0
Ann Int Rate: 0
thank you
Upvotes: 0
Views: 940
Reputation: 552
this will do
print month,"___","{:.2f}".format(monprnpaid),"___","{:.2f}".format(monintdue),"___","{:.2f}".format(loanbal)
thanks everyone
Upvotes: 0
Reputation: 4179
You need to get rid of the int
interest = float(raw_input("Interest Rate: "))
monintrate = round((interest / 100.0)/12, 4) """ will give 4 decimal places"""
annintrate = round((interest / 12), 4) """ will give 4 decimal places"""
print "Interest: ",interest
print "Mon Int Rate: ",monintrate
print "Ann Int Rate: ",annintrate
Gives the following:
Interest: 5.0
Mon Int Rate: 0.0042
Ann Int Rate: 0.41667
Upvotes: 0
Reputation: 11
Remove the int before the variables so you can get decimals
interest = float(raw_input("Interest Rate: "))
monintrate = float(( interest / 100.0 ) / 12)
annintrate = float(interest / 12)
Upvotes: 1