-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex056.py
More file actions
35 lines (26 loc) · 859 Bytes
/
ex056.py
File metadata and controls
35 lines (26 loc) · 859 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
# Leia nome, idade e sexo de 4 pessoas.
# No final o programa mostra:
# - A média de idade,
# - O nome do HOMEM mais velho,
# - Quantas mulheres tem menos de 20 anos.
print('Digite NOME, IDADE, e SEXO de 4 pessoas:')
somaIdade = 0
idadeVelho = 0
nomeVelho = ''
nMulheresNovas = 0
for i in range(4):
nome = str(input('Nome:\t\t>>>\t'))
idade = int(input('Idade:\t\t>>>\t'))
sexo = str(input('Sexo:[F/M]\t>>>\t')).lower()
print('-------------')
somaIdade += idade
if idade < 20 and sexo == 'f':
nMulheresNovas += 1
elif sexo == 'm' and idadeVelho < idade:
nomeVelho = nome
idadeVelho = idade
mediaIdade = somaIdade / 4
print('Média de idade inserida: {}'.format(mediaIdade))
print('Nº de mulheres com menos de 20: {}'.format(nMulheresNovas))
if idadeVelho != 0:
print('Nome do homem mais velho: {}({})'.format(nomeVelho,idadeVelho))