I'm working on PS1a. While I have a general understanding of what I need to do, I'm a little lost as far as beginning my code.
My first thought was to define what a prime number is in Python. I was thinking along the lines of something like:
pn= a/a == 1 and a/1 == a
These would be the two rules for primes: divisible only by 1 and itself.
I'm stuck on getting the proper code going though.
Can someone point me in the right direction? Also, is there a reference sheet explaining what Python key words, commands, etc all do?
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 :)
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.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
Rather than focusing on what a prime number is, it may help to focus on what a prime number isn't. I realize that it sounds kind of funny. What I mean is, assume that the number is prime, then try to disprove the assumption. Hopefully I can explain:
For example, try getting a list of numbers together and checking to see if there are any numbers (you only need to check numbers less than the candidate) that will divide with a remainder of 0. If so, they are not prime numbers. If you exhaust checking what a prime number isn't, then you know you have a prime number. I hope I didn't just confuse you more.
Anyway, I find the official Python documentation very useful: http://docs.python.org/index.html.
That kind of helps. A big link I'm missing is that from lectures 1-2 and the reading, I'm not understanding how I'm supposed to come up with a program that does this. The lectures are kind of vague and leave lots of holes to be filled for me.
Can you send me that link again? I can't get it to open.
Sorry, a period got pulled into the link last time: http://docs.python.org/index.html