码迷,mamicode.com
首页 > 编程语言 > 详细

《Python编程:从入门到实践》第五章 if语句 习题答案

时间:2019-09-06 12:29:30      阅读:97      评论:0      收藏:0      [点我收藏+]

标签:vivo   成年人   习题答案   编程   computer   software   exce   style   部分   

#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!")

 

《Python编程:从入门到实践》第五章 if语句 习题答案

标签:vivo   成年人   习题答案   编程   computer   software   exce   style   部分   

原文地址:https://www.cnblogs.com/zijeak/p/11474050.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!