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

Hi everyone, first post here. I've sat through the first 3 lectures and feel like I have a pretty good handle on most everything. However, when looking at problem set 1, I'm a little lost on how to even begin this. Is there anyone here that could walk me through the thought process (rather than me just looking at the solutions) so that I actually learn conceptually what I'm doing? Thank you so much! I'll do whatever I can to return the favor once I get better at this! Jarad

OpenStudy (anonymous):

I'm happy to help. What I typically do, though it is admittedly a little overkill, is I start by creating my file, and then paraphrasing the instructions in single line comments. Specifically the stated goal of the problem or function, arguments or parameters, and then the way that the output should be returned. Often the problem sets also include hints or suggestions about implementations, I definitely make sure those go in also. Once that's done, re-reading the specification and putting it into my own words has typically given me a better understanding of the problem and elements at play, and the resulting comments are basically a flow chart to solving the problem. I attack each step outlined in the comments, and write everything out at once. If you're not sure what you're writing is going to work, or you want to test an idea before committing it to the file, jump over to your real time window in idle, or open another terminal and run python on its own to try individual snippets to verify functionality or syntax. When all is written out, save and run for the example cases in the instructions, addressing errors as they come up until your answers match the test cases.

OpenStudy (anonymous):

If you want specific help regarding a problem or problem set, you must ask a specific question. Feel free to send me a message also if you prefer.

OpenStudy (rsmith6559):

I have been doing it pretty much like seandisanti, with one extra step. Before attacking it, I go through and define my functions. That just means that I design/decide what variables/arguments they need to be passed, what they'll return and how they'll do it. That way I have a good idea of how to call things, and what to expect back as I'm attacking the logic. One tip: If the coding of a section of code isn't fairly apparent, you should probably break down ( decompose ) what that section is doing into smaller sub-sections.

OpenStudy (anonymous):

Thank you all for your replies. As I said before, I really had no idea where to begin, thus I cheated and looked at the solutions and tried to work backwards to put the pieces together; figured that'd be my best bet to learn. So I think I understand the first problem in the 2nd set (the one with the credit card problems). However, This post covers the 2nd problem, and may be a little long..so I apologize! So I understand the concept of getting the raw input for the Initial Balance as well as the annual interest rate (initial starting point), but here is where some of my questions begin: MonthlyInterestRate = AnnualInterestRate / 12 (I understand this line) MonthlyPayment = 0 (Does this just mean that we're starting w 0 MonthlyPayment? Not quite sure here??) balance = InitialBalance (Just correlating the InitialBalance value to equal balance?) Those correct for the above? For the first "while" loop....can someone please confirm if the meanings of the following lines are correct? (thanks!) while balance > 0 (while there is still a balance...perform the following..) MonthlyPayment +=10 (monthly payment increases by 10 each month?) balance = InitialBalance (correlating InitialBalance rawinput to actual balance again?) numMonths = 0 (this just means start on the first month????? is that correct? this is very confusing to me..) while numMonths < 12 and balance > 0: (conditions) numMonths += 1 (one iteration/month, increase month by1) interest = MonthlyInterestRate * balance (interest/month) balance -= MonthlyPayment (take MonthlyPay out of balance) balance += interest (add interest to balance) balance = round (balance, 2) [showing final balance to 2dec places] Also....why are we nesting the 2nd "while" loop within the first? Can someone conceptually explain that to me? Why can't we just have 1 "while" loop? Just trying to piece this together...I'm very new to programming. Thanks again! I really appreciate the help a lot! I'll be sure to pay it fwd :) Hope this makes sense!

OpenStudy (rsmith6559):

When you create a variable, the machine sets aside some (maybe clean, maybe not) memory for it. Assigning a value to the variable initializes it to a known state. a += b is shorthand for a = a + b . balance = InitialBalance balance will change during the program, but InitialBalance is a static (won't change) value. Everything you've figured is basically correct. As you go on, you'll find a couple of details that at this point are just confusing.

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!