課題に取り組んでいて、障害物に遭遇しました。添付は私のコードです。このコードの目的は、開始体重、終了体重、開始身長、終了身長のユーザー入力を考慮して、bmi テーブルを作成することです。体重と身長を指定して BMI を処理する BMI 計算機も添付しました。BMI 計算機は、身長 (インチ) をメートルに、体重 (ポンド) を KG に変換します。これまでのところ、私のコードは横方向の重量と縦方向の高さを出力します。問題は、適切な BMI で内部を埋めるにはどうすればよいかということです。
def calculateBMI(height, weight):
# This will process the parameters above and convert to
# meters and pounds accordingly.
heightMeter = height * 0.0254
# This will process weight into KG where 1 pound = .4536 KG
weightKG = weight * 0.4536
# Given the new converted numbers, this will then
# calculate BMI and return the output.
calcBMI = (weightKG) / (heightMeter * heightMeter)
return calcBMI
def printBMITable(startHeight, endHeight, startWeight, endWeight):
for x in range (startWeight, endWeight + 1, 10):
print "\t",x,
print
print
for i in range(startHeight, endHeight + 1):
print i