-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathListaExercicios4_IDRS.py
105 lines (73 loc) · 2.41 KB
/
ListaExercicios4_IDRS.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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
from random import sample
valor = sample(range(100), 10)
menor = maior = valor[0]
x = 1
while x < 10:
if valor[x] < menor: menor = valor[x]
if valor[x] > maior: maior = valor[x]
x = x + 1
print('Valor: ', valor)
print(f'Menor: {menor}')
print(f'Maior: {maior}')
print()
from random import sample
par = []
impar = []
valor = sample(range(100), 20)
for x in valor:
if x % 2 == 0:
par.append(x)
else:
impar.append(x)
print('Valores: ', valor)
print('Pares: ', par)
print('Ímpares: ', impar)
print()
from random import randint
vetorA = []
vetorB = []
vetorC = []
for x in range(10):
x = randint(1, 100)
vetorA.append(x) == vetorC.append(x)
x = randint(1, 100)
vetorB.append(x) == vetorC.append(x)
print('Vetor A: ', vetorA)
print('Vetor B: ', vetorB)
print('Vetor C: ', vetorC)
print()
texto = '''The Python Software Foundation and the global Python
community welcome and encourage participation by everyone. Our community
is based on mutual respect, tolerance, and encouragement, and we are
working to help each other live up to these principles. We want our
community to be more diverse: whoever you are, and whatever your
background, we welcome you.'''.lower()
import string
for i in string.punctuation:
texto = texto.replace(i, '')
resposta = []
for letras in texto.split():
if letras[0] in 'python' or letras[-1] in 'phyton':
resposta.append(letras)
print('As seguinte palavras contém letras da palavra PYTHON:', resposta)
print()
texto = '''The Python Software Foundation and the global Python community
welcome and encourage participation by everyone. Our community is based
on mutual respect, tolerance, and encouragement, and we are working to
help each other live up to these principles. We want our community to be
more diverse: whoever you are, and whatever your background, we welcome
you.'''.lower()
import string
for i in string.punctuation:
texto = texto.replace(i, '')
resposta = []
resposta4 = []
for letras in texto.split():
if letras[0] in 'python':
resposta.append(letras)
for letras in texto.split():
if letras[0:5] in 'python':
resposta4.append(letras)
print(f'Temos {len(resposta)} palavras que contém 1 letra de PYTHON')
print(f'Temos {len(resposta4)} palavras que contém 4 letras de PYTHON')
print()