Ministério da Educação
Brasil um país de todos
Personal tools
You are here: Home Members Cicero Garrozi Disciplinas 2014 em diante Introdução à Programação Arquivos 2016-1 Algoritmos slides05-for-ex2-versao-listas.py
Navigation
Log in


Forgot your password?
 
Document Actions

slides05-for-ex2-versao-listas.py

by Cicero Garrozi last modified 2014-04-29 07:03

Click here to get the file

Size 1 kB - File type text/python-source

File contents

alturas = [1.5, 1.9, 2.0, 1.56, 1.80, 1.85, 1.67, 1.70, 1.90, 1.88, 1.75, 1.70, 1.49, 1.77, 1.75]
sexo =    ["F", "M", "M", "F",  "F",  "M",  "F",  "F",  "M",  "M",  "F",  "F",   "F",  "M", "F" ]

maior = 0
menor = 999
quantMulheres = 0
quantHomens = 0
sexoPessoaMaisAlta = ""
somaAlturaMulheres = 0.0
for i in range(15):
    if alturas[i] > maior:
        maior = alturas[i]
        sexoPessoaMaisAlta = sexo[i]
    if alturas[i] < menor:
        menor = alturas[i]
    if sexo[i] == "F":
        quantMulheres += 1
        somaAlturaMulheres += alturas[i]
    else:
        quantHomens += 1


media = float(somaAlturaMulheres / quantMulheres)
print "Maior altura: %.2f - Menor altura: %.2f"%(maior, menor)
print "Media de altura das mulheres: %.2f"%media
print "Quantidade de homens: ", quantHomens
print "Sexo da pessoa mais alta: ",sexoPessoaMaisAlta

    

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: