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

I'm pretty sure I made Problem set 1 & 2 much more difficult than necessary. Does anyone have a simplified version to share with me? I solved them in a very long fashion, also I was only able to generate the sum only on and after the 4th prime number in problem set 2. If anyone has a much more simplified version of problem set 2 please share. Here are my solutions. View source to see the Python code in the table. www.angelfire.com/realm/shirr/pythonps1.html and www.angelfire.com/realm/shirr/pythonps2.html I feel like I'm dying........

OpenStudy (anonymous):

wow I can't read it like that, maybe try dpaste.com its very simple and much easier to read EDIT: I had a error msg that a plugin failed, maybe it isn't working on my end.

OpenStudy (anonymous):

angelfire isn't working for me either. try pasting your code at dpaste.com then post the link here.

OpenStudy (anonymous):

ok, got his code off angel fire, dear god was that unnessisary, http://dpaste.com/554243/ and http://dpaste.com/554246/

OpenStudy (anonymous):

thankyou Nessman that must have taken some work! You deserve a medal for that! lol. Shirr, I don't have time immedatly to go through you code, but without too much effort I will agree with your proposition that it is more difficult than necessary. Also imagine if you had to use that method to go to 1000 numbers or a hundred thousand... Are you familiar with for loops? The first thing I would so is change it into a for loop, with a for loop you keep 'looping' through it within a range of numbers, so instead of individually typing elif statements, each of these could be a number in the range...

OpenStudy (anonymous):

I had some trouble getting for loops to work, but I'm sure with more practice in the future I'll be able to implement them in a more logical way without errors or unnecessary iterations within the code. Oh well, moving on!

OpenStudy (anonymous):

It would have given you some excellent if/elif/else practise! But you need to learn for loops, they are very useful and not so hard once you understand.

OpenStudy (anonymous):

I would hold off on moving on until you are able to work more successfully with loops and iteration. Using this kind of brute force approach will be brutal (or downright impossible) for some of the other programs as you continue.

OpenStudy (anonymous):

hear, hear

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!