# 4-2 animals = ['cat', 'dog', 'tiger'] for animal in animals: print(animal) for animal in animals: print('A ' + animal + ' would make a great pet') print('Any of these animals has a mouth!') # 4-3 nums = list(range(1,21)) print(nums) # 4-4 nums1 = list(range(1,1000001)) print(nums1) # 4-5 print(min(nums1)) print(max(nums1)) aaa = sum(nums1) print(aaa) # 4-9 list = [value**3 for value in range(1,11)] print(list) # 4-10 print("The first three items in the list are:") for num in nums[:3]: print(num) print("The last three items in the list are:") for num in nums[-3:]: print(num) # 4-13 foods = ('fish', 'beef', 'mutton', 'vegetable', 'pork') for food in foods: print(food) # foods[0] = 'apple' foods = ('apple', 'beef', 'mutton', 'banana', 'pork') for food in foods: print(food)
3.14python作業
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.