The only question (a good one) was a puzzle about two uses of a
period: in math.sqrt()
it's finding a function in a
library, in mylist.append()
it's using the
append()
method on an object of type list
.
I don't want to go into any detail at all about how Python is object oriented but not always.
Actually talked a fair amount about Tex - they'll use it more than they use Python in their ongoing mathematical education. Requiring it for hw3.
Read that code (forgot to remark on scope). Then read the TeX source for eratosthenes.pdf -- it's in the pdf.
Read the superslick pythonic Eratosthenes implementation there:
>>> noprimes = [j for i in range(2, 8) for j in range(i*2, 50,i)] >>> primes = [x for x in range(2, 50) if x not in noprimes] >>> print primes [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]