Discuss / Python / 作业

作业

Topic source

#-- coding: utf-8 --

身高单位是m 体重单位为kg

a=float(input('please input your tall:')) b=float(input('please input your weight:')) c=b/(a*a) if c<18.5: print('too thin') print('your IBM is:%.1f'%c) elif 18.5<=c<25: print('normal') print('your IBM is:%.1f'%c) elif 25<=c<28: print('too heavy') print('your IBM is:%.1f'%c) elif 28<=c<32: print('fat') print('your IBM is:%.1f'%c) else: print('too fat') print('your IBM is:%.1f'%c)

CodeYung

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

1 #!/usr/bin/env python3 2 # -- coding: utf-8 -- 3 height = 1.75 4 weight = 80.5 5 bmi = weight/(height*height) 6 bmi = round(bmi,2) 7 print(bmi) 8 if bmi<18.5: 9 print('过轻') 10 elif bmi<25: 11 print('正常') 12 elif bmi<28: 13 print('过重') 14 elif bmi<32: 15 print('肥胖') 16 else: 17 print('高于32 严重肥胖') 18 pass


  • 1

Reply