-
Notifications
You must be signed in to change notification settings - Fork 0
/
Matrizes.py
46 lines (35 loc) · 973 Bytes
/
Matrizes.py
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
# TIPO LISTA
a = [4,5,3,1,2,8,7,6,8]
print ('max(): ' + str(max(a)))
print ('min(): ' + str(min(a)))
print(10 *'=' + '> testes')
#casos de testes
assert a[0] == 4
assert a[1] == 5
assert a.index(3) == 2
#tudo eh uma sequencia no python
lista = ["a", "b", "c"]
temp = "abc"
assert lista[0] == temp[0]
#Slices
print(10 *'=' + '> Slices')
print(a[3:7]) #pega do indice 3 ao indice 7 => >=3 and <7
print(10 *'=')
#multiplica por dois todos os elementos
newList = [el*2 for el in a]
print(newList)
#entender o reverse
print([4,5,3,1,2,8,7,6,8].reverse()) #funciounou no exo 18
print(reversed([4,5,3,1,2,8,7,6,8]))
print([4,5,3,1,2,8,7,6,8][::-1])
print(10 *'=')
#entender o sort
print([4,5,3,1,2,8,7,6,8].sort())
print(sorted([4,5,3,1,2,8,7,6,8]))
print(10 *'=')
#Stack
print('Stack pop(): ' + str(newList.pop()))
#Join e converte cada caracter em string
print('Join: ' + ' * '.join([str(el) for el in newList]))
#Organiza, remove duplicidades, ordena
print(set(a))