内容正文:
2.3程序设计基本知识
P60实践活动
编程计算体重指数程序设计答案:
a=float(input('请输入身高米:'))
b=float(input('请输入体重千克:'))
BMI=b/(a*a)
print("体重指数BMI=",round(BMI,2)) #保留1位小数
P63实践活动
评定体重指数等级程序设计答案:
第2题:方案一
b=float(input('请输入身高米:'))
c=float(input('请输入体重千克:'))
bmi=c/pow(b,2)
t=bmi
print("你的体重指数BMI的值是:",round(t,1))
if t>=16.5 and t<=23.3:
print("正常")
else :
if t<=16.4:
print('低体重')
else:
if t>=23.3 and t<=26.3:
print("超重")
else:
print("肥胖")
方案二:多分支结构
b=float(input('请输入身高米:'))
c=float(input('请输入体重千克:'))
bmi=c/(b*b)
t=bmi
print("体重指数BMI的值是:",round(t,1))
if t>=16.5 and t<=23.3:
print("正常")
elif t<=16.4:
print('低体重')
elif t>=23.3 and t<=26.3:
print("超重")
else:
print("肥胖")
第3题:
a=input('请输入性别:')
e='男'
f="女"
if a!=e and a!=f:
print("性别输入错误")
else:
b=float(input('请输入身高米:'))
c=float(input('请输入体重千克:'))
bmi=c/pow(b,2)
t=bmi
if a==e:
if t>=16.5 and t<=23.3:
print("正常")
elif t<=16.4:
print('低体重')
elif