-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgeneradores.py
More file actions
51 lines (34 loc) · 777 Bytes
/
generadores.py
File metadata and controls
51 lines (34 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#generador tiempo
#lista memoria
#normal
lista3=[]
for i in range(5):
lista3.append(i)
print(lista3)
#comprimido
lista = [i for i in range(5)]
print(lista)
#generador
lista2 = (i for i in range(5))
print(lista2)
lista_ejemplo =[5,5,31,2,123,30,90,80,214,324,23,43,12,54,32,34,35]
def div_five(num):
if num % 5 == 0:
resultado = True
else:
resultado= False
return resultado
xyz = (i for i in lista_ejemplo if div_five(i))
'''xyz = []
for i in lista_ejemplo:
if div_five(i):
xyz.append(i)'''
[print(i) for i in xyz]#list comprenhension
#(print(i) for i in xyz)#generator
[[print(i,ii) for ii in range(5)]for i in range(5)]
for i in range(5):
for ii in range(5):
print(i,ii)
xyz =[[print[i,ii] for ii in range(5)]for i in range(5)]
for i in xyz:
i