Discuss / Python / 求大神解释 输入整数可以 输入小数点就错误

求大神解释 输入整数可以 输入小数点就错误

Topic source

wangtao2046

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

-- coding: utf-8 --

weight=int(input ('你的体重:')) height=int(input ('你的身高:')) bmi = (weight/height)**2 if bmi <= 18.5: print('过轻') elif 18.5 > bmi >= 25: print('正常') elif 25> bmi >= 28: print('过重') elif 28 > bmi >= 32: print('肥胖') elif bmi > 32: print('严重肥胖')

pass

hdhdindjdjd

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

你接收的是整数类型,但是处理的结果是浮点数,能不出错吗?

wangtao2046

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

怎么都不行

紫陌-尘

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

使用浮点数定义

wangtao2046

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

谢谢

NoArya

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

float(input())


  • 1

Reply