-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex095.py
69 lines (64 loc) · 2.09 KB
/
ex095.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
'''
Aprimore o DESAFIO 093 para que ele funcione com vários jogadores, incluindo
um sistema de visualização de detalhes do aproveitamento de cada
jogador.
'''
futebol = {}
jogadores = []
gol = []
while True:
futebol['Nome'] = str(input('Nome do jogador(a): '))
# Validação das partidas.
while True:
futebol['Partidas'] = int(input('Partidas jogadas: '))
if futebol['Partidas'] <= 0:
print('Resposta inválida!')
else:
break
for c in range(0, futebol['Partidas']):
# Validação dos gols
while True:
g = int(input(f'Gols na {c + 1}ª partida: '))
if g < 0:
print('Resposta inválida!')
else:
break
gol.append(g)
futebol['Gols'] = gol[:]
futebol['Total de Gols'] = sum(gol)
jogadores.append(futebol.copy())
gol.clear()
# Validação da pergunta
while True:
perg = str(input('Quer continuar? [S/N]')).strip().upper()[0]
if perg in 'SN':
break
else:
print('Resposta inválida!')
if perg in 'N':
break
print('=' * 35)
print(f'{"Nº":<} {"NOME":<10}{"PARTIDAS":<10}{"TOTAL DE GOLS":>}')
for i, l in enumerate(jogadores):
print(f'{i + 1:<}º {l["Nome"]:<10} {l["Partidas"]:<10} {l["Total de Gols"]:>}')
print('=' * 35)
while True:
perg1 = str(input('Quer ver o aproveitamento de cada jogador? [S/N] ')).strip().upper()[0]
if perg1 in 'S':
# Verificação do número do jogador
while True:
jg = int(input('Qual jogador? (999 para sair)'))
if jg <= 0 or (jg - 1) > len(jogadores):
print('Resposta inválida!')
elif jg == 999:
break
else:
print('-' * 35)
print(f'{"APROVEITAMENTO":^25}')
print('-' * 35)
print(f'{"Nº":<10}{"NOME":<10}{"GOLS":>10}')
print(f'{jg:<10}{jogadores[jg - 1]["Nome"]} {jogadores[jg - 1]["Gols"]}')
elif perg1 in 'N':
break
else:
print('Resposta inválida!')