[英]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)
I placed the print statement in the definition and made the name arguement into a string.我将 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)
edit: added user input编辑:添加用户输入
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.