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

Hi, I have a question regarding Pset 1 part B Why can't I use the same formula from part A for testing the ending balance of the year and get the same result? I tried and it would get me vastly different answers. Also, why do we need the balance = initialBalance in the state variables AND in the first 'while' section? Isn't that redundant?

OpenStudy (anonymous):

did you read the instructions? the main focus of the course is computer science, not programming if you tried a different algorithm and got different results, maybe you didn't implement it correctly. post your code. please use a code pasting site: - http://dpaste.com - http://pastebin.com - https://gist.github.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.

OpenStudy (anonymous):

^Yes, i did read the instructions although I'm not sure what you mean by CS vs programming. here is the code: https://gist.github.com/anonymous/5942114 Thanks for your help.

OpenStudy (anonymous):

your algorithm mutates balance in the inner loop it looks like you want to 'start over' in the outer loop but when you start the outer loop for the second time balance will not equal the initial balance. can you describe in words what your code does? print statements are a great tool for showing what is going on while your program is running - i added line 7, http://dpaste.com/1291302/

OpenStudy (anonymous):

ah i see it now. Thanks a bunch. I was trying to maintain the original balance when i was starting over but i see now why i have to do the balance = initial balance thing. i'll mess around with that and see what I come up with.

OpenStudy (anonymous):

writing down, in words, the steps you need to take to solve the problem before you write the code helps also

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!
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!