zoukankan      html  css  js  c++  java
  • if 语句


    personHeight = input("请输入你的身高(m)")
    personHeight = float(personHeight)
    personWeight = input("请输入你的体重(kg)")
    personWeight = float(personWeight)
    personAge = input("请输入你的年龄:")
    personAge = int(personAge)
    personSex = int(input("请输入你的性别(男:1,女:0)"))
    personSex = int(personSex)

    #容错处理,数据有效性的验证

    if not (0 < personHeight < 3 and 0 < personWeight < 300 and 0 < personAge < 150 and (personSex == 1 or personSex == 0)):
    print("输入的数据有误")
    exit()


    BMI = personWeight / (personHeight * personHeight)
    TZL = (1.2 * BMI + 0.23 * personAge - 5.4 - 10.8 * personSex) / 100

    # if personSex == 1:
    # print("男性的体脂率为0.15----0.18")
    # elif personSex == 0:
    # print("女性的体脂率为0.25---0.28")
    # else:
    # print("输入有误")
    minNum = 0.15 + 0.10 * ( 1 - personSex )
    maxNum = 0.18 + 0.10 * ( 1 - personSex )
    re = minNum <= TZL <= maxNum
    # print("你的体脂率是:%f" % TZL )
    # print("你的体脂率是否符合标准",re)
    if personSex == 1:
    n = "先生您好"
    minNum = 0.15
    maxNum = 0.25
    elif personSex == 0:
    n = "女士您好"
    minNum = 0.18
    maxNum = 0.28
    else:
    print("输入有误")

    if re:
    m = "您的身体良好,请保持"
    else:
    if TZL > maxNum:
    m = "您的身体偏胖"
    else:
    m = "您的身体偏瘦"
    print(n,m)




  • 相关阅读:
    抓包工具之Charles
    docker之服务搭建
    Linux之查看开放端口
    Centos7下的开机自启动
    phpredis和predis
    Redis迁移工具之Redis-shake
    服务器间文件实时双向同步(rsync+inotify)
    Linux之轨迹记录(script)
    Redis集群之常用操作
    Redis集群搭建-多服务器
  • 原文地址:https://www.cnblogs.com/houchaoying/p/12957445.html
Copyright © 2011-2022 走看看