您的位置:首页 > 编程语言 > Python开发

【python】第四次课作业

2018-03-14 23:12 666 查看
4-1pizzas = ['dasd', 'gthy', 'hyt', 'oiuy']
for pizza in pizzas:
print(pizza)
for pizza in pizzas:
print("I like "+pizza+"pizza.")
print("I really love pizza!")


4-3~4-9for i in range(1, 4):
print(i)
three = [value**3 for value in range(1,5)]
print(three)


4-10names = ['Karry', 'Roy', 'Jackson', 'Leo', 'Nemo', 'Lucky']
print("Total list is:")
print(names)
print("The first three items in the list are:")
print(names[:3])
print("The last three items in the list are:")
print(names[-3:])
print("Three items from the middle of the list are:")
print(names[2:5])


4-11pizzas = ['dasd', 'gthy', 'hyt', 'oiuy']
friend_pizzas = pizzas[:]
pizzas.append('bcshj')
friend_pizzas.append('ql')
print("My favorite pizzas are:")
for pizza in pizzas:
print(pizza)
print("My frined's favorite pizzas are:")
for pizza in friend_pizzas:
print(pizza)


4-13foods = ('dsdf', 'rew', 'eret', 'oiu', 'cvx')
for food in foods:
print(food)
print("After some change:")
foods = ('akj', 'rew', 'eret', 'pijdhf', 'cvx')
for food in foods:
print(food)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: