一個郁悶的問題
height?=?1.78
weight?=?65
def?Bmi(height,weight):
????bmi?=?(weight?/?height?*?height)
????if?bmi?<?18.5:
????????print?('過輕')
????elif?18.5?<=?bmi?<?25:
????????print?('正常')
????elif?25?<=?bmi?<?28:
????????print?('過重')
????elif?28?<=?bmi?<?32:
????????print?('肥胖')
????else?:
????????print?('嚴重肥胖')
Bmi(height,weight)將bmi = (weight / height * height)中的‘height * height’
替換為‘ height**2’?就能得到正確的答案?
x ** 2和x*x ?的結果不一樣么?
2016-09-04
計算順序有問題,(weight?/?height?*?height)的計算結果就是weight,正確的寫法是(weight?/ (height?*?height))