zoukankan      html  css  js  c++  java
  • 《Python编程:从入门到实践》第五章 if语句 习题答案

    #5.1
    major = 'Software Engineering'
    print("Is major =='Software Engineering'? I predict True.")
    print(major=='Software Engineering')
    
    print("Is major =='Software Engineering'? I predict False.")
    print(major=='Computer Science')
    #5.2
    print("--------------------------------------")
    string_1='abc'
    string_2='abc'
    string_3='abcd'
    print("Is string_1==string_2? ")
    print(string_1==string_2)
    print("Is string_2==string_3?")
    print(string_2==string_3)
    print("--------------------------------------")
    print("Is string_1 == string_1.lower()?")
    print(string_1==string_1.lower())
    print("--------------------------------------")
    print("这个部分实在过于简单和麻烦,略过!")
    print("--------------------------------------")
    print(True and False)
    print(True and True)
    print(False and False)
    print(True or False)
    print(True or True)
    print(False or False)
    print("--------------------------------------")
    mobileInc = ['apple','xiaomi','huawei','oppo','vivo']
    print('apple' in mobileInc)
    print('coolpad' in mobileInc)
    print('nokia' not in mobileInc)
    
    #5.3
    alien_color = 'green'
    if alien_color == 'green':
        print("Great!You got 5 point!")
    alien_color = 'red'
    if alien_color == 'green':
        print("Great!You got 5 point!")
    print("------------------------------------")
    #5.4
    alien_color = 'green'
    if alien_color == 'green':
        print("Great!You got 5 point!")
    else:
        print("Excellent!You got 10 point!")
    alien_color = 'red'
    if alien_color == 'green':
        print("Great!You got 5 point!")
    else:
        print("Excellent!You got 10 point!")
    print("-----------------------------------------")
    #5.5
    alien_color = 'green'
    if alien_color == 'green':
        print("Great!You got 5 point!")
    elif alien_color == 'yellow':
        print("Excellent!You got 10 point!")
    elif alien_color == 'red':
        print("Oh,my god!You got 15 point!")
    
    
    alien_color = 'yellow'
    if alien_color == 'green':
        print("Great!You got 5 point!")
    elif alien_color == 'yellow':
        print("Excellent!You got 10 point!")
    elif alien_color == 'red':
        print("Oh,my god!You got 15 point!")
    
    
    alien_color = 'red'
    if alien_color == 'green':
        print("Great!You got 5 point!")
    elif alien_color == 'yellow':
        print("Excellent!You got 10 point!")
    elif alien_color == 'red':
        print("Oh,my god!You got 15 point!")
    print("-----------------------------------------")
    
    #5.6
    age = 33
    if age < 2:
        print("婴儿")
    elif age>=2 and age<4:
        print("蹒跚学步")
    elif age>=4 and age<13:
        print("儿童")
    elif age>=13 and age<20:
        print("青少年")
    elif age>=20 and age<65:
        print("成年人")
    elif age>=65:
        print("老年人")
    
    #5.7
    favourite_fruits = ['apple','banana','orange']
    if 'apple' in favourite_fruits:
        print("You really like apples!")
    if 'banana' in favourite_fruits:
        print("You really like bananas!")
    if 'orange' in favourite_fruits:
        print("You really like orange!")
    if 'watermalen' in favourite_fruits:
        print("You really like watermalen!")
    if 'grape' in favourite_fruits:
        print("You really like grape!")
  • 相关阅读:
    安装jupyter
    git 查看分支图
    Docker原生健康检查使用
    压力测试指标判定
    Docker限制日志
    docker link 过时不再用了?那容器互联、服务发现怎么办?(2017年文章,建议使用docker network自定义网络)
    Nginx配置TCP服务负载均衡
    【转让】看看有你喜欢的书籍嘛?--都是我翻过的。
    《SOD框架企业级应用数据架构实战》新书简介和预定
    一年之计在于春,2015开篇:PDF.NET SOD Ver 5.1完全开源
  • 原文地址:https://www.cnblogs.com/zijeak/p/11474050.html
Copyright © 2011-2022 走看看