I went through the first problem set (the one that had us write programs to pay off credit card debt). I didn't struggle with the actual programming, but I thought that the hardest part was trying to figure out what the formula would be for the different payments. Is that ok?
Here is the problem set http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00sc-introduction-to-computer-science-and-programming-spring-2011/unit-1/lecture-4-machine-interpretation-of-a-program/MIT6_00SCS11_ps1.pdf
it IS OK that you thought part of the problem was hard. want to post your solution? please use a code pasting site: - http://dpaste.com - http://pastebin.com - http://www.repl.it/ - http://pastie.org - http://codepad.org - http://ideone.com paste your code there and post the link here. select Python syntax highlighting when u paste.
here is the first part. i'll post the rest later today. http://dpaste.com/hold/1225193/ what do you think?
the result of floating point math is a float - you don't need to coerce so many variables to float. does it work?
It mostly works. The only inconsistency is that my program is with how my program round the final decimal. For example, the total amount paid for the first example in the answer key is $1131.12, but my program returns it as $1131.11. How serious is this as a programming error?
why do you think it is an 'error' what were the parameters - balance, interest rate, payment rate? I can't seem to find the 'answer key' The main idea of the problem set is described as : "This problem set will introduce you to using control flow in Python and formulating a computational solution to a problem"
your code cleans up quite a bit when all the xtra 'float()'s are removed http://dpaste.com/1227748/
here is the answer key: http://dpaste.com/1227768/ let me know what you think
that solution rounds during calculations - which i think is (technically) incorrect. I think the correct solution would only round during printing - like you did. so the difference is a rounding error but the main topic of the pset is flow control and formulating computational solutions
Because you know the time period is going to be 12 months, you can also use a 'for' syntax instead of a 'while', see: http://dpaste.com/1232335/
Join our real-time social learning platform and learn together with your friends!