In [1]:
l = [i**2 for i in range(5)]

In [2]:
print(l)


[0, 1, 4, 9, 16]

In [3]:
print(type(l))


<class 'list'>

In [4]:
g = (i**2 for i in range(5))

In [5]:
print(g)


<generator object <genexpr> at 0x10af944f8>

In [6]:
print(type(g))


<class 'generator'>

In [7]:
for i in g:
    print(i)


0
1
4
9
16

In [8]:
g_cells = ((row, col) for row in range(0, 3)
           for col in range(0, 2) if col == row)

In [9]:
print(type(g_cells))


<class 'generator'>

In [10]:
for i in g_cells:
    print(i)


(0, 0)
(1, 1)

In [11]:
print(sum([i**2 for i in range(5)]))


30

In [12]:
print(sum((i**2 for i in range(5))))


30

In [13]:
print(sum(i**2 for i in range(5)))


30

In [14]:
t = tuple(i**2 for i in range(5))

In [15]:
print(t)


(0, 1, 4, 9, 16)

In [16]:
print(type(t))


<class 'tuple'>