[英]bmi calculator how do restart the calculator to go back to yes/no at the top
Take_Bmi=(input("Take bmi yes or no "))
if Take_Bmi == "yes":
name1=input(" enter your name")
height_m1=input(" enter your height in m")
weight_kg1=input(" enter your weight")
def bmi_calculator(name1,height_m1,weight_kg1):
bmi = float(weight_kg1) / (float(height_m1)** 2)
#輸入function返回一個字符串。 所以要得到你的 output 你#需要使用“float()”來計算身高和體重:print("bmi:")
if bmi < 25 :
print(bmi)
return name1 + " not overweight"
else:
print(bmi)
return name1 + " is overweight"
result= bmi_calculator(name1,float(height_m1),float(weight_kg1))
print(result)
else:
print("thank you")
input
function 返回一個字符串。 因此,要獲得 output,您需要使用“float()”來計算身高和體重:
bmi = float(weight_kg1) / (float(height_m1)** 2)
此外,您必須致電您的 function,例如
bmi_calculator(name1,float(height_m1),float(weight_kg1))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.