我目前正试图为我的类完成一个Python问题,但我似乎无法理解最后一部分
Question: Using a second loop it should traverse the array of body mass indices and call another function that accepts the body mass index as a parameter and returns whether the individual is underweight, normal weight, or overweight. The number of individuals in each category should be counted and the number in each of those categories should be displayed. You should decide on the names of the six individuals and the thresholds used for categorization.
这是我到目前为止为我的项目编写的代码
#Tell the user the purpose of this program
print ("This program will help calculate the body mass index of 6 people")
#create a list of names based of what the user inputs
individuals = list()
for i in range(6):
user = str(input("Please enter the names of the 6 users who want to calculate their BMI: "))
#add user to the list of individuals
individuals.append(user)
BMIs = []
for user in individuals:
print("Calculating for", user)
#promt each individual for their height and weights
height = int(input(user + ", in inches, how tall are you? "))
weight = int(input(user + ", in pounds, how much do you weight? "))
#append the BMI to the array
BMIs.append(user + ", your BMI is: " + str(weight * 703/height**2))
#print the individuals BMIs from the BMI list
for BMI in BMIs:
print(BMI)
#function that accepts BMI as a parameter
weight = BMIs
def individuals(weight):
for BMI in weight:
if BMI > 30:
print(user + ", is OVERWEIGHT")
elif BMI < 18.5:
print(user + ", is underweight")
else:
print(user + ", is within the NORMAL")
下一步我能试试什么
目前没有回答
相关问题 更多 >
编程相关推荐