I'm working ps2 of p1 in the 2012 course. I want to know how to solve this problem without defining variables in python. I tried 20 mor times. I'm getting error. Anyway,Thanks .. This is my code... month = 0 totalPayment = 0.0 """balance =float(raw_input("balance \n")) annualInterestRate =float(raw_input("annualInterestRate \n")) monthlyPaymentRate =float(raw_input("monthlyPaymentRate \n"))""" while month < 12 : if (balance != 0)and (balance > 0): month = month + 1 monthlyInterestRate = annualInterestRate / 12 monthlyPayment = monthlyPaymentRate * balance print " \n\n\n The minimum monthly payment for month",month,"is " ,round(monthlyPayment,2) totalPayment = totalPayment + monthlyPayment print " \n The total amount paid for month",month,"is ", round(totalPayment,2) balance = (balance - monthlyPayment)*(1 + monthlyInterestRate) print " \n the remaining balance for month",month,"is ",round(balance,2) else: print " \n monthly payment and the remaining balance ",str(balance)," " ,str(totalPayment) break print " \n \n total payment " print round(totalPayment,2) print " remaining balance" print round(balance,2) The output from the grader.. We couldn't run your solution. Please help me..
u dont need to define them at all.....no raw inout no nothing...since their grader does that automatically.....just write it as if they were defined.
plus ur code is extrimely long and complicated or better said "dressed" go for a more clean and simple way. gl
I agree with @MicroBot clean out those raw inputs an try to cut out the fat from this code; it's darn hard to read!
Actually your code seems fine if you cut out the raw inputs. Just don't forget to assign a value for monthly payment rate and you should be fine.
There may be a chance that the grader wants you to print things out with the prompts it gives you. It may not like the fact that you altered the print statements. That's just a guess though.
What @TuringTest says about the print statement for the grader, is true .It wants u to have the exsact output.
Dont you need something also to calculate the total paid?
Join our real-time social learning platform and learn together with your friends!