# Revision history [back]

Note that you can use (1 .. 20) to iterate through the integers from 1 to 20, without constructing the list of these integers, as [1 .. 20] does.

To obtain an iterator of squares:

 sage: (k^2 for k in (1 .. 20))


To obtain the list of squares:

sage: [k^2 for k in (1 .. 20)]


To obtain the sum of squares:

sage: sum(k^2 for k in (1 .. 20))