簡體   English   中英

bmi 計算器如何重新啟動計算器到 go 回到頂部的是/否

[英]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")

我怎么喜歡像打印一樣重復這個測試(你想再拿一次嗎)

回到頂部你想帶 bmu 是 / 否

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM