Advertisement
Guest User

altura python_robert

a guest
Oct 31st, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.22 KB | None | 0 0
  1. print ('Verificaremos: a maior e a menor altura do grupo, média de altura das mulheres e o número de homens')
  2. n=int(raw_input('Digite a quantidade de pessoas do grupo: '))
  3. somam=qtdh=qtdm=menor=maior=0
  4. while menor==0:
  5.     a=raw_input('Digite o sexo(m ou f): ')
  6.     if a=='m':
  7.         qtdh+=1
  8.         b=float(raw_input('Digite a altura: '))
  9.         menor=b
  10.         maior=b
  11.     if a=='f':
  12.         qtdm+=1
  13.         c=float(raw_input('Digite a altura: '))
  14.         somam+=c
  15.         menor=c
  16.         maior=c
  17. for i in range(1,n):
  18.     a=raw_input('Digite o sexo(m ou f): ')
  19.     if a=='m':
  20.         qtdh+=1
  21.         b=float(raw_input('Digite a altura: '))
  22.         if b>maior:
  23.             maior=b
  24.         if b<=menor:
  25.             menor=b                
  26.     if a=='f':
  27.         qtdm+=1
  28.         c=float(raw_input('Digite a altura: '))
  29.         somam+=c
  30.         if c>maior:
  31.             maior=c
  32.         if c<=menor:
  33.             menor=c                        
  34. print ('A maior altura do grupo é: '), maior
  35. print ('A menor altura do grupo é: '), menor
  36. print ('A quantidade de homens é: '),qtdh
  37. if qtdm==0:
  38.     print('Nenhuma mulher no grupo')
  39. else:
  40.     print ('A média de altura das mulheres é: '),somam/qtdm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement