-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex065.py
More file actions
43 lines (32 loc) · 841 Bytes
/
ex065.py
File metadata and controls
43 lines (32 loc) · 841 Bytes
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
# Crie um programa que leia vários inteiros.
# Mostre a média, o maior e o menor valores lidos
# O programa pergunta a cada vez se o usuário quer continuar
def wantsToLeave():
result = ''
while not result in ['S', 'N']:
result = input('Deseja sair? [S/N]\n>>>\t').strip().upper()
return result == 'S'
soma = 0
maior = 0
menor = 0
ctr = 0
continuar = True
while continuar:
curr = float(input('Digite um número:\n>>>\t'))
soma += curr
if ctr == 0:
maior = curr
menor = curr
elif curr > maior:
maior = curr
elif curr < menor:
menor = curr
ctr += 1
continuar = not wantsToLeave()
print('----------------')
print('Resultados carregados!')
print('Maior:\t{}'.format(maior))
print('Menor:\t{}'.format(menor))
print('# ins:\t{}'.format(ctr))
print('Soma:\t{}'.format(soma))
print('Média:\t{}'.format(soma / ctr))