And finally that the primes are consecutive, that is there are no other primes hiding in this range of numbers:

>>> forxinrange(min(PRIMES_TO_SUM),max(PRIMES_TO_SUM)+1):… ifisprime(x):… ifxinPRIMES_TO_SUM:… print"%s is prime and already in PRIMES_TO_SUM"%x… else:… raiseException("%s is prime and not in PRIMES_TO_SUM"%x)… else:… print"%s is not prime"%x… 157 is prime and already in PRIMES_TO_SUM158 is not prime159 is not prime160 is not prime161 is not prime162 is not prime163 is prime and already in PRIMES_TO_SUM164 is not prime165 is not prime166 is not prime167 is prime and already in PRIMES_TO_SUM168 is not prime169 is not prime170 is not prime171 is not prime172 is not prime173 is prime and already in PRIMES_TO_SUM174 is not prime175 is not prime176 is not prime177 is not prime178 is not prime179 is prime and already in PRIMES_TO_SUM180 is not prime181 is prime and already in PRIMES_TO_SUM182 is not prime183 is not prime184 is not prime185 is not prime186 is not prime187 is not prime188 is not prime189 is not prime190 is not prime191 is prime and already in PRIMES_TO_SUM192 is not prime193 is prime and already in PRIMES_TO_SUM194 is not prime195 is not prime196 is not prime197 is prime and already in PRIMES_TO_SUM198 is not prime199 is prime and already in PRIMES_TO_SUM200 is not prime201 is not prime202 is not prime203 is not prime204 is not prime205 is not prime206 is not prime207 is not prime208 is not prime209 is not prime210 is not prime211 is prime and already in PRIMES_TO_SUM

We can also phrase these as assertions, which will raise an error if false:

While I have no reason to doubt the good professor's claim, I thought it might
be fun to check it out. A little googling (yeah, I was feeling very lazy) found
a "Python isprime()
function":http://www.daniweb.com/forums/post319401.html#post319401:

{{ d['sections']['check-prime-2011.py|idio']['is-prime'] }}

And we can use this to verify that 2011 is a prime number:
{{ d['sections']['check-prime-2011.py|idio|pycon|pyg']['2011-is-prime'] }}

Next let's check that the list of numbers given does indeed add up to 2011:
{{ d['sections']['check-prime-2011.py|idio|pycon|pyg']['primes-to-sum'] }}

And that they are all, in fact, prime:
{{ d['sections']['check-prime-2011.py|idio|pycon|pyg']['check-all-prime'] }}

And finally that the primes are consecutive, that is there are no other primes
hiding in this range of numbers:
{{ d['sections']['check-prime-2011.py|idio|pycon|pyg']['check-consecutive'] }}

We can also phrase these as assertions, which will raise an error if false:
{{ d['sections']['check-prime-2011.py|idio']['assertions'] }}

And since the source for this blog post is tiny, let's just include it here:
<notextile><pre>
{{ d['index.txt|wrap']|e }}
</pre></notextile>

And here is the Python script in full:
{{ d['check-prime-2011.py|pyg'] }}

Raw source code is of course available at <a
href="http://bitbucket.org/ananelson/dexy-blog">bitbucket</a>.

### @export "check-consecutive"forxinrange(min(PRIMES_TO_SUM),max(PRIMES_TO_SUM)+1):ifisprime(x):ifxinPRIMES_TO_SUM:print"%s is prime and already in PRIMES_TO_SUM"%xelse:raiseException("%s is prime and not in PRIMES_TO_SUM"%x)else:print"%s is not prime"%x