4-13
food = ('apple', 'meat', 'fish', 'icecream', 'cake') for item in food: print(item) food = ('pineapple', 'meat', 'fish', 'ice', 'cake') for item in food: print(item)
5-1
food = 'apple' print("Is food == 'apple'?I guess True.") print(food == 'apple') print("Is food == 'pineapple'?I guess False.") print(food == 'pineapple')
5-2
str1 = 'apple' str2 = 'pineapple' str3 = 'apple' print("Is str1 == str2?") print(str1 == str2) print("Is str1 == str3?") print(str1 == str3) str1 = 'HELLO' str2 = 'hello' print("Is str1 == str2?") print(str1.lower() == str2) print('1 == 1') print(1 == 1) print('1 != 1') print(1 != 1) print('1 > 2') print(1 > 2) print('1 < 2') print(1 < 2) print('1 >= 2') print(1 >= 2) print('1 <= 2') print(1 <= 2) if (1 == 1) and (2 > 1): print('hello') if (1 != 1) or (2 < 1): print('no') if (1 != 1) or (2 > 1): print('yes') food = ['apple', 'banana', 'coconut'] if 'apple' in food: print('in') if 'chocolate' not in food: print('not in')
标签:apple,16,food,str2,str1,item,print,Day From: https://www.cnblogs.com/IslandNeo/p/16900939.html