In [ ]:
a = [x for x in range(5)]
print(a)
In [ ]:
a = [x for x in range(10) if x % 2 == 0]
b = [x if x % 2 == 0 else -x for x in range(10)]
print(a)
print(b)
In [ ]:
a = [(x, y) for x in range(10) for y in range(5)]
print(a)
print(len(a))
In [ ]:
combs = [(x, y) for x in [1, 2, 3] for y in [3, 1, 4] if x != y]
print(combs)
type(combs)
In [ ]:
combs = []
for x in [1,2,3]:
for y in [3,1,4]:
if x != y:
combs.append((x, y))
print(combs)
In [ ]:
x = [x + 1 for x in [y for y in range(0, 100, 15)]]
print(x)
In [ ]:
x = (x for x in range(100) if x % 2 == 0 and x % 5 == 0)
print(x)
print(type(x))
for el in x:
print(el)
In [ ]:
x = {x for x in range(25) if x % 2 == 0}
print(x)
print(type(x))
for el in x:
print(el)
In [ ]:
x = { x: x + 1 for x in range(25) if x % 2 == 0}
print(x)
print(type(x))
for key, value in x.items():
print(key, value)