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