MIT 6.00 Intro Computer Science (OCW)
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.
your code es hard to reading. in my opinion this code is more readeble una funcion me facilita trabajar con codigo muy extenso. se puede reutilizar y a mi parecer de eso se trata todo el punto 1 http://dpaste.com/778396/
I am quite lost, what is the purpose of the script?
use two loops, one inside the other http://dpaste.com/779923/
That is a really good idea, now I just have the problem that it hits an infinite loop at append.primes(n) where it appends n an infinite amount of times until it hits 1000 in primes_found... Can you see why it does that? Because I don't get why. http://dpaste.com/781781/
this might be closer to what you wanted http://dpaste.com/781844/
That actually seems to be exactly what I wanted :D But just for the sake of me understanding it better I hope you don't mid me asking: 1: What does the and p == primes += 1 part do for the process exactly? and 2: why did my code not work? And what I mean by that is, that by my logic it should be working and looping properly (witch was clearly not the case for the looping part) so I think I wasn't communicating properly to the interpreter what I wanted it to do, but I don't really see why it did not loop as I wanted. It can then be discussed that your version was more effective putting check_int += 1 in the start of the loop instead of in all the conditionals and stuff like that, but my question is still about the looping. Thanks a lot :D
i didn't actually try your code - the first thing i saw is that the loop at line nine uses check_int_list but check_int_list never gets updated - you would be usinf the same number over and over. then, it looks like the loops at lines 8 and 9 are reversed - you want to test your number against all the primes in the list - for each number you want to check you want to run thru the list of primes. it helps to write down in words a sort of pseudocode explaining what you are trying to do - then turn it into code - it is easier than just trying to write the code off the top of your head. print statements are a good way to debug your code - it lets you see what is actually happening so you can compare to what you intended - here is your code with print statements - http://dpaste.com/782220/ I added p == primes[-1] because you cannot say a number is prime till you have tested it with all the previous primes. [-1] is a slice that points to the last item in a list - i think the tutorial in the Python docs covers slices. += is an operator that adds the number on the right to the number on the left. a+=1 is equivalent to a = a+1. This operator is listed in the Python documentation which should be installed on your computer (F1 from within Idle).