anonymous
  • anonymous
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)
katieb
  • katieb
See more answers at brainly.com
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.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

anonymous
  • anonymous
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.
anonymous
  • anonymous
That looks like mine.
anonymous
  • anonymous
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).

Looking for something else?

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

More answers

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

Looking for something else?

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