Stuck on problem set 1 (I am very new to programming). How should I go about writing the program for finding the 1000th prime number? Is it all written in conditionals?
Stop and think about what you've learned about primes over the years. Some of the little tidbits can make a dramatic speed increase in this program. Data structures can be very helpful, and faster too. For all programs, don't try to solve the whole problem at once. Break the problem down into smaller, easier to solve sections. Keep breaking it down until you can solve a section in about 10 to 15 lines of code. I have started to use the description of what the program needs to do (the problem description), usually one phrase or sentence at a time, to set out the goal of a function or section of code. It gives me a comment, and a goal for the code.
to find my short answer, I took the problem to a notepad first, and penned down what my goals were, questions that came to mind, then I started to code answers(solve problems). then, flowchart, and voila, a viable program evolved in a few hours. Actual coding was approximately 1.5 hours, the other 7 hours were spent "playing computer". i.e. researching python, reading assignments, searching open study answers. I hope this helps
Join our real-time social learning platform and learn together with your friends!