-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathmatriz.py
More file actions
76 lines (59 loc) · 1.53 KB
/
matriz.py
File metadata and controls
76 lines (59 loc) · 1.53 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Clase 3 matrice
lista = [
[0, 1, 2, 3],
[4, 5, 6, 7]
]
print(lista[1])
print(type(lista[1]))
# ahora quiero acceder a la posicion:
# 1, 2 de mi matriz:
print(lista[1][2])
for filas in lista:
for col in filas:
print(col)
# Ranking de musica:
# Posicion, Nombre del Artista
# 1, Maluma
# 2, Blackpink
# 3, Calamaro
# 4, Radiohead
ranking = [[1, "Maluma"], [2, "Blackpink"], [3, "Calamaro"], [4, "Radiohead"]]
for r in ranking:
print("En la posicion: ", r[0], "El artista: ", r[1])
# Dos ejercicios:
# 1) Invertir el ranking, es decir
# quiero ver desde el ultimo al primero:
# 2) Tengo la siguiente lista
# [4, 5, 2, 7, 6, 101, 5, 5, 3]
#
# Quiero saber cual es el numero mas alto?
# Y cual el mas bajo?
# A todo esto quiero el indice o posicion del
# numero mas alto o mas bajo
numeros = [4, 5, 2, 7, 6, 101, 5, 5, 3]
maximo = numeros[0]
indice_max = 0
for x in range(0, len(numeros)):
if numeros[x] > maximo:
maximo = numeros[x]
indice_max = x
print("Mi maximo es: ", maximo)
print("Y esta en la posicion: ", indice_max)
# Resolucion ejercicio 1:
# 1) Invertir el ranking, es decir
# quiero ver desde el ultimo al primero:
ranking = [[1, "Maluma"], [2, "Blackpink"], [3, "Calamaro"], [4, "Radiohead"]]
for x in ranking:
print(x)
for x in range(0, len(ranking)):
print(ranking[x])
#invertido = []
#for x in ranking:
# invertido.append(x)
invertido = []
x = len(ranking) -1
while x >= 0:
invertido.append(ranking[x])
print(x)
x -= 1
print("Mi lista final es: ", invertido)