Discuss / Python / float 是浮点数,字符串是无法运算的,小白弄了半天

float 是浮点数,字符串是无法运算的,小白弄了半天

Topic source

Joooodler

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

-- coding: utf-8 --

h = float(input('你的身高是多少(单位:米)')) w = float(input('你的体重是多少(单位:千克)')) b = w/(h * h) print('你的BMI指数是:%.1f' % b) if b > 32 : print('您的体形:严重肥胖') elif b >= 28 : print('您的体形:肥胖') elif b >= 25 : print('您的体形:过重') elif b >= 18.5 : print('您的体形:正常') else : print('您的体形:过轻')


  • 1

Reply