Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python BMI计算总是以英制单位显示肥胖_Python_Python 3.x - Fatal编程技术网

Python BMI计算总是以英制单位显示肥胖

Python BMI计算总是以英制单位显示肥胖,python,python-3.x,Python,Python 3.x,BMI计算器,当我输入英语单位时,它显示我肥胖,不管答案是什么,有点困惑,我如何修复这个错误 print ("Body Mass Index Calculator") Unit = input("Metric or English?: (enter M or E)") if Unit == "M": Weight = float(input("Please enter your weight(kg):")) Height = float(input("Please enter y

BMI计算器,当我输入英语单位时,它显示我肥胖,不管答案是什么,有点困惑,我如何修复这个错误

print ("Body Mass Index Calculator")
Unit = input("Metric or English?: (enter M or E)")
if Unit == "M":
    Weight = float(input("Please enter your weight(kg):"))
    Height = float(input("Please enter your height(m):"))
    BMI = (Weight/ Height**2)
    print ("BMI:",Weight /Height**2)
else:
    Unit == "English"
    weight = float(input("Please enter your weight(lb):"))
    height = float(input("Please enter your weight(in):"))
    BMI = (weight /height *height *703)
    print ("BMI:",weight /height**2 *703)

if BMI<=18.5:
    print ("Underweight")
elif BMI>=18.5 and BMI<=24.9:
    print ("Normal weight")
elif BMI>=25.0 and BMI<=29.9:
    print ("Overweight")
else:`enter code here`
    print ("Obese")
打印(“体重指数计算器”)
单位=输入(“公制或英制:(输入M或E)”)
如果单位=“M”:
重量=浮动(输入(“请输入您的重量(kg):”)
高度=浮动(输入(“请输入您的高度(m):”)
体重指数=(体重/身高**2)
打印(“体重指数:”,体重/身高**2)
其他:
单位==“英语”
重量=浮动(输入(“请输入您的重量(磅):”)
高度=浮动(输入(“请输入您的体重:”)
体重指数=(体重/身高*身高*703)
打印(“体重指数:”,体重/身高**2*703)

如果BMI=18.5,BMI=25.0,BMI您的BMI变量是错误的,但由于某种原因,您的BMI变量在它的正下方是正确的,请将BMI更改为:

BMI = (weight /height**2 *703)
输出:

Metric or English?: (enter M or E)E
Please enter your weight(lb):150
Please enter your weight(in):72
BMI: 20.341435185185187
Normal weight

你的体重指数公式是错误的

替换

BMI = (weight /height *height *703)


这是你的问题:
BMI=(体重/身高*身高*703)
这一行有效地评估为
BMI=weight*703
,这可能是肥胖。让它成为一个
BMI=(体重/身高**2*703)
,就像你在仪表块中所做的那样,事情应该会很顺利
BMI = (weight*703) /height**2