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

What's wrong with this code: balance = 4213 annualInterestRate = 0.2 monthlyPaymentRate = 0.4 month = 1 balance = (balance - (balance*monthlyPaymentRate))*(1+(annualInterestRate/12)) while month < 13: print "Month: " + str(month) print "Minimum monthly payment: " + str(round(minimum_payment_rate, 2)) print "Remaining balance: " + str(round(balance, 2)) month += 1

OpenStudy (turingtest):

you have your while loop not affecting the balance

OpenStudy (anonymous):

Please explain

OpenStudy (turingtest):

after "while month <=13" all you have are print statements you are not using each month to alter the current balance

OpenStudy (turingtest):

balance = (balance - (balance*monthlyPaymentRate))*(1+(annualInterestRate/12)) the way that you have your code you are only performing this operation once i.e. you only make one payment

OpenStudy (turingtest):

what you want to do is re-code this so that that operation happens each month

OpenStudy (turingtest):

and minimum pay rate is not defined, as Python will tell you

OpenStudy (anonymous):

You should be calculating the balance based off the payments you make in a 12 month period and then repeating this as you increase the payment to find the correct payment amount.

OpenStudy (anonymous):

yes bro, that' the responds I get from python

OpenStudy (turingtest):

well that's an easy one to fix you have not defined the variable minimum_payment_rate at any point in the code is this problem 1 or 2 in pset2 ?

OpenStudy (anonymous):

pset1

OpenStudy (turingtest):

yeah, so you need a formula for minimum_monthly_payment in terms of variables you have already defined you have already written it earlier, you just need to identify it what is the formula for minimum_monthly_payment ?

OpenStudy (anonymous):

it is (Minimum monthly payment rate) x (Previous balance)

OpenStudy (turingtest):

yeah, which you wrote already as...?

OpenStudy (anonymous):

I don't think I have written it in my code

OpenStudy (turingtest):

you don't see balance times monthly payment in your code?

OpenStudy (anonymous):

yes I have written it in the balance = (balance - (balance*monthlyPaymentRate))*(1+(annualInterestRate/12)), if this is what you are asking for

OpenStudy (turingtest):

yes

OpenStudy (turingtest):

the variable you wrote to print, minimum_monthly_payment, is completely undefined in your code. you may as well have written print purple_turtle you just invented a variable replace it with the stuff we have defined...

OpenStudy (anonymous):

so I should remove the print statement of print "Minimum monthly payment: " + str(round(minimum_payment_rate, 2)) and replace it with print purple_turtle?

OpenStudy (turingtest):

have we defined purple_turtle ? no, my point is to replace it with something that you have defined again (it's on the webpage with the problem) what is the formula for minimum monthly payment?

OpenStudy (anonymous):

this is it (Minimum monthly payment rate) x (Previous balance)

OpenStudy (turingtest):

and how did you code minimum monthly payment rate?

OpenStudy (anonymous):

that's where my confusion comes in

OpenStudy (turingtest):

you gave it a name, you called it monthlyPaymentRate that is probably more of a hint than I should have given you

OpenStudy (anonymous):

are you saying that anywhere I see monthlyPayingRate I should replace it with purple_turtle.

OpenStudy (turingtest):

no, I'm saying that where you see the \(undefined\) variable minimum_monthly_payment you should replace it with the \(defined\) variables monthlyPaymentRate*(something) you're gonna have to figure out the something for yourself.

OpenStudy (anonymous):

ok, I want to know how to make python understand the 'minimum_monthly_payment'

OpenStudy (turingtest):

minimum_monthly_payment=balance*monthlyPaymentRate that is all the help I'm going to give you since the deadline is still not up yet your code has another issue, but you will have to deal with that one on your own. Good luck!!

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!