Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

Looking for help on anyway that I might be able to better optimize this simple program for the 6.00sc Problem set1 I have posted the code on http://dpaste.com/hold/1322328/

MIT 6.00 Intro Computer Science (OCW)
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer

SEE EXPERT ANSWER

To see the expert answer you'll need to create a free account at Brainly

Looks good to me, just in case you didn't know you can use %s in print statements to make it easier to format. Have a look here: http://stackoverflow.com/questions/5954260/default-substituting-s-in-python-scripts Also, you can abbreviate x=x+1 with x += 1.
That looks like mine.
I'm not a big fan of "while" loop when you just want to scope through a predetermined set of values. It is easy to get stuck in an infinite loop (but thats not the case here). I would go for a "for" loop : for x in range(1,13): intpaid = apr/12*balance princ = balance*minpayrate-intpaid print 'Minimun amount you must pay is ' +str (round(balance*minpayrate,2)) print 'Interest paid in month '+str (x),': $' +str (round(intpaid,2)) print 'Principal paid in month '+str (x),': $' +str (round(princ,2)) balance = balance -princ print 'Remaining balance is: ' +str (round(balance,2)) total = total + (princ + intpaid) print 'Amount paid out over '+str(x) +' months is $'+str (round(total,2)) BTW, kudos for calling round() on results. I dont understand why ppl keep rounding values at the very start of the program, as it impacts results precision (however, i agree it is sometime desirable).

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Maybe thats better if i give a readable output: http://dpaste.com/1323844/
i don't see any reason to optimize your solution. is it running too slow?

Not the answer you are looking for?

Search for more explanations.

Ask your own question