-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path46 - Analisando pesos v.2.py
More file actions
51 lines (39 loc) · 1.41 KB
/
46 - Analisando pesos v.2.py
File metadata and controls
51 lines (39 loc) · 1.41 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
# VERSÃO 2.
people = list()
people_data = list()
while True:
name = str(input('Nome: '))
people_data.append(name)
weight = float(input('Peso: '))
people_data.append(weight)
# Inserir o nome e idade da pessoa na lista 'people' e depois
# zerar a lista 'people_data' para cadastra outra pessoa.
people.append(people_data[:])
people_data.clear()
answer = ' '
while answer not in 'SN':
answer = input('Deseja cadastrar mais alguém? [S/N] ').upper()
if answer == 'N': break
# Fazer um loop em todas as pessoas comparando apenas seus pesos.
# Armazenar o menor e o maior peso em variáveis.
greater_weight = lower_weight = 0
for p in people:
# A primeira pessoa é quem possui o maior e menor peso, já que só tem ela.
if p[1] in people[0]: # Primeiro loop.
greater_weight = lower_weight = p[1]
elif p[1] > greater_weight:
greater_weight = p[1]
elif p[1] < lower_weight:
lower_weight = p[1]
# Resultado para o usuário.
print('\n','=-='*8, 'RESULTADO', '=-='*8, '\n')
print(f'Total de {len(people)} pessoas.')
print(f'O menor peso registrado foi {lower_weight}kg e o maior {greater_weight}kg.')
print(f'As pessoas com mais de 90kg são: ', end='')
for p in people:
if p[1] > 90:
print(f'[{p[0]}]', end='')
print(f'\nAs pessoas com menos de 60kg são: ', end='')
for p in people:
if p[1] < 60:
print(f'[{p[0]}]', end='')