anonymous
  • anonymous
Here is my code for Problem Set 1. Any ways to condense code? Part 1: http://dpaste.com/725513/ Part 2: http://dpaste.com/725516/ Both work fine. Ask away if you are stuck.
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
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.
schrodinger
  • schrodinger
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
congrats here is mine, i stored all the primes in a list and kept looking till there were 1000 items in the list - http://dpaste.com/725633/
anonymous
  • anonymous
Wow, your script is so nice and concise, and it works too:o. Too bad I don't really understand what you did b/c i don't know much of the more complex syntax. Good job though, hopefully after i'm done this course I can go back and understand what you did haha.
anonymous
  • anonymous
bwCA: nice solution. Attached is my version. I short circuited 2 and 3. Hope this helps.
1 Attachment

Looking for something else?

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

More answers

anonymous
  • anonymous
kevinw198: regarding my second solution I used log where you used log (,10). Our answers defer and I don't know which one is the correct. Maybe someone can throw in his/her answers into the mixture. My solution seems to agree with the ratio becoming 1 as the primes become larger. Hope this helps.
1 Attachment
anonymous
  • anonymous
kevinw198: If I remove the log(,10) and replace it with log -- I think this is natural log and change the lines (there are two) ratio=n/sum to ratio=x/sum we match.
anonymous
  • anonymous
I don't know why I used based 10 instead of natural log. I assumed natural log was "ln" function, and in high school, log base 10 was usually just written as log for me. But I think the code is correct though. I looked at your solution, but I didn't really understand what the break function does.
anonymous
  • anonymous
The break function serves to exit from within a loop and continue from the first line after. Imagine you have a for loop from 1 to 1000. In order "jump out" you use break. Hope this helps.
anonymous
  • anonymous
http://docs.python.org/reference/simple_stmts.html#the-break-statement http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#testing-for-truth-values The only thing i did different was store the primes in a list. http://docs.python.org/tutorial/introduction.html#lists http://docs.python.org/tutorial/datastructures.html#more-on-lists

Looking for something else?

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