I am stuck writing a program to calculate bmi and categorizing them.
individuals = list()
for i in range(6):
user = str(input("Please enter the names of the 6 users who want to calculate their BMI: "))
individuals.append(user)
BMIs = []
for user in individuals:
print("Calculating for", user)
height = int(input(user + ", in inches, how tall are you? "))
weight = int(input(user + ", in pounds, how much do you weight? "))
BMIs.append(user + ", your BMI is: " + str(weight * 703/height**2))
for BMI in BMIs:
print(BMI)
if int(BMI)< 16:
print( user + "BMI is:" + str(bmi) + "and you are:severely underweight")
elif int(BMI)>= 16 and bmi < 18.5:
print( user + "BMI is:" + str(bmi) + "and you are:severely underweight")
elif int(BMI) >= 18.5 and bmi < 25:
print( user + "BMI is:" + str(bmi) + "and you are:severely Healthy")
elif int(BMI)>= 25 and bmi < 30:
print( user + "BMI is:" + str(bmi) + "and you are:severely overweight")
elif int(BMI) >=30:
print( user +" " + "BMI is:" + str(bmi) + "and you are:severely overweight")
the if statements dont work and i cant figure how to categorize those who are overweight, healthy
Had to make quite a few changes to make this work:
individuals = list()
for i in range(6):
user = str(input("Please enter the names of the 6 users who want to calculate their BMI: "))
individuals.append(user)
BMIs = []
messages = []
for user in individuals:
print("Calculating for", user)
height = int(input(user + ", in inches, how tall are you? "))
weight = int(input(user + ", in pounds, how much do you weight? "))
BMIs.append(weight * 703 / height ** 2)
messages.append(user + ", your BMI is: " + str(BMIs[-1]))
for m in messages:
print(m)
for u in zip(individuals, BMIs):
if u[1] < 16:
print(u[0] + "BMI is:" + str(u[1]) + " and you are:severely underweight")
elif 16 <= u[1] < 18.5:
print(u[0] + "BMI is:" + str(u[1]) + " and you are:severely underweight")
elif 18.5 <= u[1] < 25:
print(u[0] + "BMI is:" + str(u[1]) + " and you are:severely Healthy")
elif 25 <= u[1] < 30:
print(u[0] + "BMI is:" + str(u[1]) + " and you are:severely overweight")
elif u[1] >= 30:
print(u[0] + " " + "BMI is:" + str(u[1]) + " and you are:severely overweight")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.