Hi. I was trying to solve second problem of Set01 (Paying debt off in 1 year). Code is below. I get a syntax error on the first print command inside the while loop. Could anyone tell me why? Thanks.
``` OutBalance=float(raw_input('Enter purchased value: ')) AIR=float(raw_input('Enter annual interest rate: ')) #AIR = Annual Interest Rate month=0 PaidInterest=0 MinPay=0 MinPay=round(((AIR/((1-(1/(1+AIR)**12))))*OutBalance),0) while MinPay%10!=0: MinPay+=1 if MinPay%2==0: print MinPay for n in range(0,12): while OutBalance>0: month+=1 PaidInterest=OutBalance*(AIR/12) Amort=MinPay-PaidInterest OutBalance=OutBalance*(1+(AIR/12)-MinPay print ("Month is: ", month) print 'Paid interest is: ',PaidInterest print 'Amortization is: ',Amort print 'Remainind balance is ',OutBalance print MinPay,' is the min payment required' print '' ```
The problem is not with the print statement but the line of code before it. You did not close your parenthesis. OutBalance=float(raw_input('Enter purchased value: ')) AIR=float(raw_input('Enter annual interest rate: ')) #AIR = Annual Interest Rate month=0 PaidInterest=0 MinPay=0 MinPay=round(((AIR/((1-(1/(1+AIR)**12))))*OutBalance),0) while MinPay%10!=0: MinPay+=1 if MinPay%2==0: print MinPay for n in range(0,12): while OutBalance>0: pass month+=1 PaidInterest=OutBalance*(AIR/12) Amort=MinPay-PaidInterest OutBalance = (OutBalance*(1+(AIR/12)-MinPay)) print "Month is: %s", month print 'Paid interest is: ',PaidInterest print 'Amortization is: ', Amort print 'Remainind balance is ',OutBalance print MinPay,' is the min payment required' print ''
What bbkzr31 is taling about is this line: ``` OutBalance=OutBalance*(1+(AIR/12)-MinPay ``` Two ( one ).
Hahahahaha such a silly mistake =P Thanks folks =)
Well, here is my code: ``` OutBalance=float(raw_input('Enter purchased value: ')) AIR=float(raw_input('Enter annual interest rate: ')) #AIR = Annual Interest Rate MIR=AIR/12 month=0 PaidInterest=0 MinPay=0 MinPay=round((OutBalance*MIR*((1+MIR)**12))/(((1+MIR)**12)-1),0) while MinPay%10!=0: MinPay+=1 if MinPay%2==0: print MinPay for n in range(0,12): while OutBalance>0: month+=1 PaidInterest=round(OutBalance*(MIR),2) Amort=round((MinPay-PaidInterest),2) OutBalance=round((OutBalance-(MinPay-(OutBalance*MIR))),2) print ("Month is: ", month) print 'Paid interest is: ',PaidInterest print 'Amortization is: ',Amort print 'Remainind balance is ',OutBalance print MinPay,' is the min payment required' if OutBalance<0: print 'Number of months is: ',str(11) else: print 'Number of months is: ',str(12) print '' ``` Thing is, I used French Amortization System formula for finding a minimum payment needed, then I rounded to first multiple of 10. I don't think this is the major idea of programming, i.e. using formulas. Any tips you could give me? I've tried to state a minimum payment equal to 10, then try it. If it does not work, it should be incremented by 10. Once again I'd use another formula.
And I reckon the month computation code is not proper...
Join our real-time social learning platform and learn together with your friends!