Discuss / Python / 作业

作业

Topic source

LeborYi

#1 Created at ... [Delete] [Delete and Lock User]
import math
#为了使用平方的算法,导入math模块

def bmi(height,weight):
    return weight / (height ** 2)

h = float(input("请输入身高:"))
w = float(input("请输入体重:"))
b = bmi(h,w)
print('你的BMI指数是:%.2f' % b)

if b <= 18.5:
    print('你太轻惹,需要增肥!')
elif b <= 25:
    print('恭喜你,你的体重是正常的!')
elif b <= 28:
    print('你有一点点重哦~')
elif b <= 32:
    print('你的体重已经过了国家线啦,需要强力减肥!')
else:
    print('少年,你的体质异于常人!')

liweichen6

#2 Created at ... [Delete] [Delete and Lock User]

height ** 2 不需要 import math 吧 import math 了以后可以 math.pow()


  • 1

Reply