我正在执行一项任务并且遇到了障碍。附上我的代码。这段代码的目的是在给定用户输入的起始重量、结束重量、起始高度和结束高度的情况下开发一个 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