-2
maior50 = menor20 = maior10 = 0
x = 1
while x <= 20:
idad = int(input("Digite sua idade:"))
alt = float(input("Digite sua altura:"))
peso = float(input("Digite seu peso:"))
x = x + 1
if idad >= 50:
maior50 += 1
if idad <= 20:
menor20 += 1
elif idad >= 10:
maior10 += 1
if idad < 40:
medpeso = peso * 20 / 100
med = maior10 + menor20 / 2
print(f"Total de pessoas maiores de 50 Anos: {maior50}")
print("A média das alturas das pessoas com idade entre 10 e 20 anos é:%d"%med)
print("A porcentagem de pessoas com peso inferior a 40 quilos entre todas as pessoas é:%d"%medpeso)
Develop a program that reads the age, height and weight of 20 people. Validate data entry. This program should calculate and display:
- a) The number of persons over the age of 50;
- b) The average height of persons aged between 10 and 20;
- c) The percentage of persons weighing less than 40 kilograms among all persons.
I wonder if the way I did is correct.
No, and I would recommend that you make one table test to understand what your code does.
– Woss
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).
– Maniero