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

I need help on problem 1 part 2 I know you have to do a for loop for the monthly payment and a nested for loop for the months but something about my code is not right: x = float(raw_input('Enter the outstanding balance on your credit card: ')) y = float(raw_input('Enter the annual credit card interest rate as a decimal: ')) MMP = 0 MIR = y/12.0 month = 0 for MMP in range(0, 1200, 10): NB = x*(1+MIR) - MMP for i in range(1, 13): NB = x*(1+MIR) - MMP x = NB print NB print MMP if NB >= 0: month += 1 else: break

OpenStudy (anonymous):

and it cut off my print code but I have that below the else: break part

OpenStudy (amistre64):

what is it spose to do? and what is it doing?

jaynator495 (jaynator495):

Welcome To OpenStudy! Here you will find great helpers and friends, a community of students that help students! We hope you enjoy the experience!

OpenStudy (anonymous):

Use a for loop within a while loop. Set the while loop condition so that it will terminate when the balance hits 0 or less. This is how i wrote it: out_balance = float(raw_input("Enter the outstanding balance on your credit card: ")) annual_interest = float(raw_input("Enter the annual credit card interest rate as a decimal: ")) monthly_interest = (annual_interest/12.0) + 1.0 min_pay = 0 updated_balance = out_balance while updated_balance = out_balance: updated_balance = out_balance min_pay += 10 for month in range(1, 13): updated_balance = updated_balance * monthly_interest - min_pay if updated_balance <= 0.0: break print "RESULT" print "Monthly payment to pay off debt in 1 year: " , min_pay print "Number of months needed: " , month print "Balance: " , round(updated_balance, 2)

OpenStudy (anonymous):

Thank you so much, that was very helpful! Although I will say it didn't work until I changed the while loop to: while updated_balance >= 0: etc. etc.

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
Countless7Echos: Ah trying out the whole T.V girl drawing :p (I love drawing eyes)
1 hour ago 8 Replies 5 Medals
kaelynw: starting to draw a hand
2 days ago 16 Replies 2 Medals
Twaylor: Rate it :D (Took 2 days)
2 days ago 7 Replies 0 Medals
XShawtyX: Art, Short Writing Assignment: Imagining Landscapes
4 hours ago 7 Replies 1 Medal
XShawtyX: Chemistry, Help ud83dude4fud83cudffe
3 days ago 13 Replies 1 Medal
kaelynw: tried a lil smt, the arm is off but i like the other stuff
3 days ago 27 Replies 3 Medals
kaelynw: art igg
3 days ago 14 Replies 1 Medal
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!