美文网首页
2018-12-02 BMI等级判断

2018-12-02 BMI等级判断

作者: 子小亦大 | 来源:发表于2018-12-02 19:40 被阅读0次

BMI等级判断

#CalBMI.py

try:

    h,w = eval(input("input hight(cm) and weight(kg):"))

except:

    print("the input is wrong, should like '175,75'")

else:

    bmi = w / pow(h/100, 2)

    print("the bmi value is {:.8f}".format(bmi))

    who,nat = "",""

    if bmi < 18.5:

        who,nat = "slim","slim"

    elif 18.5 <= bmi < 24:

        who,nat = "normal","normal"

    elif 24 <= bmi < 25:

        who,nat = "normal","fat"

    elif 25 <= bmi < 28:

        who,nat = "fat","fat"

    elif 28 <= bmi < 30:

        who,nat = "fat","too fat"

    else:

        who,nat = "too fat","too fat"

    print("the bmi level is: WHO {}, NAT {}".format(who,nat))

finally:

    print("come on!!!")

相关文章

网友评论

      本文标题:2018-12-02 BMI等级判断

      本文链接:https://www.haomeiwen.com/subject/ozkscqtx.html