所以我需要计算BMI的计算次数,并在循环结束时打印出来。有什么想法吗?你知道吗
print("Hello and welcome to the BMI calculator!!")
user = input("Would you like to go again, Y/N: ")
while user == "y":
height = int(input("Please put in your height in Meters: "))
weight = int(input("Please put in your weight in Kilogram: "))
BMI = weight/ (height*height)
if BMI < 18:
print("Your BMI is:", BMI, "Eat some more Big Macs, you are too skinny!")
elif BMI > 25:
print("Your BMI is:", BMI, "Stop eating all those Big Macs, you are far too fat!")
elif BMI >18 < 25:
print("Your BMI is:", BMI, "You are a normal and healthy weight, congratulations!!!")
user = input("Would you like to go again, Y/N: ")
input("\nPress the enter key to exit")
相当简单。只需在循环外生成一个变量,并在每次循环开始时递增它。你知道吗
相关问题 更多 >
编程相关推荐