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)




  • 相关阅读:
    前端cookie操作用到的一些小总结
    sublime 官方正版,自己用的插件配置,最轻量级安装流程
    Node.js 终端输出颜色设置
    Mac中设置别名 (转载)
    Swift 3 使用objc_setAssociatedObject
    ruby 笔记
    编程模式
    rvm pod gem 等常用命令
    node.js 笔记
    Node.js 对象合并
  • 原文地址:https://www.cnblogs.com/houchaoying/p/12957445.html
Copyright © 2011-2022 走看看