BMI 指數(即身體質量指數,簡稱體質指數又稱體重,
英文為Body Mass Index,簡稱BMI),
是用體重公斤數除以身高(米)平方得出的數字
print('----歡迎使用BMI計算程序----')
name=input('請鍵入您的姓名:')
height=eval(input('請鍵入您的身高(m):'))
weight=eval(input('請鍵入您的體重(kg):'))
gender=input('請鍵入你的性別(F/M):')
BMI=float(float(weight)/(float(height)**2))
#公式
if BMI<=18.4:
print('姓名:',name,'身體狀態:偏瘦')
elif BMI<=23.9:
print('姓名:',name,'身體狀態:正常')
elif BMI<=27.9:
print('姓名:',name,'身體狀態:稍重')
elif BMI>=28:
print('姓名:',name,'身体状态:過重')
import time;
#time模块
nowtime=(time.asctime(time.localtime(time.time())))
if gender=='F':
print('感谢',name,'女士在',nowtime,'使用本程序,祝您身體健康!')
if gender=='M':
print('感谢',name,'先生在',nowtime,'使用本程序,祝您身體健康!')