0
我想學習Python有毛病我的計算,並作爲測試我試圖做一個BMI計算器在Python
#BMI Calculator
name = raw_input ("What is your name?: ")
weight = raw_input ("Hello %s What is your weight? (kilo): "% (name))
height = raw_input ("And what is your height? (cm) ")
#Calculations: weight/height^2 * 10000
weight = int(weight)
height = int(height)
BMI = (weight/height ** 2) * 10000
print "%s, your BMI is %s"% (name, BMI)
但似乎有一些錯誤的計算,因爲我總是BMI爲0?怎麼了?
你使用Python 2,我猜?除非你病態肥胖,否則「身高」將大於「體重」,所以答案將會是零。 –
更改此線BMI =(體重/身高** 2)*浮動(10000) – Eliethesaiyan
甚至更好BMI =(體重/浮動(身高)** 2)* 10000 – Eliethesaiyan