Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

minimallinux

  • 2 years ago

I seem to be missing something in pset2 see code balance = 4213 annualInterestRate = 0.2 monthlyPaymentRate = 0.04 mmp = monthlyPaymentRate*balance m = 1 while(m <=12): print 'Month: ', m m += 1 print 'Minimum monthly payment: ',round(mmp,2) balance = (balance - mmp)*(1 + monthlyPaymentRate) mmp = monthlyPaymentRate*balance print 'Remaining balance: ',round(balance,2) It's first attempt, doesn't match the test case for reduction in values in fact it seems a draconian rate, i cant see why. Thanks

  • This Question is Closed
  1. rsmith6559
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Two things that will help you. First and most importantly, when you're not comfortable with the math that you're going to be doing, comment the heck out of it. That will help you check that you're code is doing exactly what you intended. Second, for debugging, print the answer after each calculation to make sure that things are progressing just as you expect.

  2. TuringTest
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    balance = (balance - mmp)*(1 + monthlyPaymentRate) ^^^^ why is this MPR? shouldn't it be monthly interest rate?

  3. TuringTest
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    That, and you need a total paid variable to keep track of, along with the print statements at the end for final balance and total paid.

  4. medisynergi
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    it would help if you posted the original formula from the problem.

  5. minimallinux
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Its using the basic formula provided, but doesn't seem to work balance = (balance - mmp)*(1 + monthlyPaymentRate) is supposed to be the new balance after removing the payment and adding interest @Turing Test, yes that is the monthly interest rate

  6. Chris2332
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    I would suggest solving the problem in paper first and understand how to reach to a solution. Then use programming to help you get the solution faster. In my opinion. you have not fully understood the problem judging by your code. If you solve it in paper, it should be straight forward to code it! *Note the the rest, as I have mentioned to other posts... since the deadline for the exercise has not passed, we should not be providing full solutions in here! Just something to remember!

  7. minimallinux
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    It prints out in the format required but the maths is not correct. Even if I separate the monthly payment subtraction from the preceding balance and the adding on of interest it is still not right.

  8. Chris2332
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    If the maths are not correct, then you need to revisit the problem on paper. Forget programming for the moment and focus on understanding and solving the problem. There are tips and instructions on the problem set page to help you get started!

  9. minimallinux
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    There must be one of my variables I have calculated wrongly, as the others are preset. This must be the mmp which I have as = monthlyPaymentRate*balance

  10. Chris2332
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Which of the 3 exercises in problem set 2 are you stuck?

  11. minimallinux
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    The 1st one, paying the minimum.

  12. Chris2332
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    As described on the page of the problem: To help you get started, here is a rough outline of the stages you should probably follow in writing your code: For each month: - Compute the monthly payment, based on the previous month’s balance. - Update the outstanding balance by removing the payment, then charging interest on the result. - Output the month, the minimum monthly payment and the remaining balance. - Keep track of the total amount of paid over all the past months so far. Print out the result statement with the total amount paid and the remaining balance. Use these ideas to guide the creation of your code. These are step by step instructions on how to approach the problem! Let me know if you have any issues!

  13. medisynergi
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    balance = (balance - mmp)*(1 + monthlyPaymentRate) that is incorrect.

  14. minimallinux
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Not according to this

    1 Attachment
  15. bwCA
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    you should look very carefully at the pic that you posted and the line that medisynergi posted

  16. minimallinux
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    So monthlyPaymentRate and monthly InterestRate are not the same ?

  17. bwCA
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    read the problem instructions/specifications again

  18. Chris2332
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    One is interest rate on the amount owed, the payment rate is the monthly instalment!

  19. minimallinux
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    so it should be monthlyInterestRate and be set at 18/12

  20. minimallinux
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Evidently not

  21. Chris2332
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    0.18/12 what is 18? interest rate is a percentage!

  22. minimallinux
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Annual rate 18%

  23. Chris2332
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    exactly... 18% = 18/100 = 0.18, not 18

  24. minimallinux
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    OK Thanks.

  25. minimallinux
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    It's still wrong though while(m <=12): print 'Month: ', m m += 1 print 'Minimum monthly payment: ',round(mmp,2) balance = (balance - mmp)*(1 + 0.18/12) paid = mmp + paid print 'Total paid: ',paid mmp = monthlyPaymentRate*balance print 'Remaining balance: ',round(balance,2) Can't seem to get it

  26. Chris2332
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Do you have a solution in paper? It seems that you don't!

  27. minimallinux
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    No its wrong on paper too, I'm not getting right the subtraction of mmp and the subsequent adding of the compound interest. Back to the drawing board. (I haven't done maths for well over 30 years so need a little slack here. I've also only tried Python for 2-3 weeks)

  28. Chris2332
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Not trying to agitate you... Just suggesting that you should take a step back and think the solution of the problem on paper first with small steps.

  29. minimallinux
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I finally got it right ! Passed grader, I was very close all the time but I didn't use the annualInterestRate in the balance calculation/12 (for monthly interest) You are right though, I am rushing without thinking too much at all. Thanks again.

  30. Chris2332
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Not a problem... we are always here to help but the more you try the better for you!

  31. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Ask a Question
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.