簡體   English   中英

嘗試創建 BMI 計算器的 python 中的 NameError

[英]NameError in python trying to create a BMI calculator

def bmi_calculator(name,height_m,weight_kg):

        bmi = weight_kg / (height_m ** 2)

print('Your bmi is: ', bmi)
  
bmi_calculator(yerson,1.8,65)

我將 print 語句放在定義中,並將名稱爭論變成了一個字符串。

def bmi_calculator(name,height_m,weight_kg):

    bmi = weight_kg / (height_m ** 2)
    print('Your bmi is: ', bmi)


name = input("What is your name: ")
height = float(input("What is your height: "))
weight = float(input("What is your weight: "))

bmi_calculator(name,height,weight)

編輯:添加用戶輸入

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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