美文网首页从零开始学Python
P4:判断体重(python版)

P4:判断体重(python版)

作者: iLester | 来源:发表于2018-01-27 20:35 被阅读21次

    说明:代码研习社20189春的活动示例代码,活动说明及其他成员递交的地址:http://yun.zjer.cn/index.php?r=studio/activies/activiesdetail&sid=531&aid=9241

    # coding:utf-8
    
    def getAnswer(height, weight):
        standard = (height -100) * 0.9
        if weight > standard:
            return "偏胖"
        elif weight < standard:
            return "偏瘦"
        else:
            return "标准"
    
    height = input('please input your height(CMs):')
    weight = input('please input your weight(KGs):')
    
    height = int(height)
    weight = int(weight)
    
    print('身高:{} cm。'.format(height))
    print('体重:{} kg。'.format(weight))
    answer = getAnswer(height, weight)
    print('你的体重:'+ answer )
    
    

    运行结果:


    output

    相关文章

      网友评论

        本文标题:P4:判断体重(python版)

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