Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 15 Online
OpenStudy (anonymous):

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..

OpenStudy (microbot):

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.

OpenStudy (microbot):

plus ur code is extrimely long and complicated or better said "dressed" go for a more clean and simple way. gl

OpenStudy (turingtest):

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!

OpenStudy (turingtest):

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.

OpenStudy (turingtest):

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.

OpenStudy (microbot):

What @TuringTest says about the print statement for the grader, is true .It wants u to have the exsact output.

OpenStudy (anonymous):

Dont you need something also to calculate the total paid?

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!