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

ps1b question... bal = float(raw_input("Enter the outstanding balance on your " "credit card: ")) annual_rt = float(raw_input("Enter the annual credit card interest " "rate as a decimal: ")) monthly_rt = annual_rt / 12 monthly_pymt = 0.0 balance = bal while balance > 0.0: monthly_pymt += 10 month = 0 balance = bal while balance > 0 and month < 12: month += 1 balance = balance * (1 + monthly_rt) - monthly_pymt print "months needed", month print "monthly payment needed"

OpenStudy (anonymous):

I figured out that an embedded while loop was necessary but why do you have to initialize a new "balance" variable and why do you have to initialize it again inside the first while loop?

OpenStudy (anonymous):

Because in the line balance = balance * (1 + monthly_rt) - monthly_pymt the Right Hand Side has a balance, so that needs to have a value, otherwise the expression has no value and then the a new value for balance cannot be assigned. The same goes for monthly_pymt After twelve months you try with an augmented monthly_pymt, and since it is a new try, you have to start with the initial balance

OpenStudy (anonymous):

Hi tendaytripper! From what I understand the answer needs to print all 12 months with all the details within each of the months. That is why you need to initialize a new balance variable so then within each month the variable of balance updates and shows you exactly what the remaining balance is, the principle paid, interest paid, minimum monthly payment is, etc etc… for that month….and at the end it'll show you after a year how much we're getting screwed by credit card institutions….lol but you know thats a whole different thing altogether….anyways, printing your answer on IDLE i noticed its not displaying like the homework for the other examples….I believe you'll need to include a for loop with a count and range….so it'll display how I said it….i got that far….but i don't know how to get the values to update within the for loop…..let me know where you are….i would love to collaborate! Thanks!

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!
Latest Questions
Mari103: How to pop out like a Jacc In the box
19 minutes ago 0 Replies 0 Medals
Breathless: Spooky witch but cute
7 hours ago 3 Replies 0 Medals
Arriyanalol: help
7 hours ago 10 Replies 2 Medals
Arriyanalol: @tinydinoUwU stop trying to find a argument u blad lil boy
1 day ago 5 Replies 4 Medals
Jaded012023: Please tell me what you all think of this song
9 hours ago 6 Replies 1 Medal
Arriyanalol: bro how
9 hours ago 2 Replies 3 Medals
Arriyanalol: cant wait for the new bluey movie in 2027
1 day ago 12 Replies 2 Medals
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!