《Python编程——从入门到实践》第四章部分习题解

# 4-2
animals = ['cat' , 'tiger' , 'leopard']
for animal in animals:
	print(animal)
for animal in animals:
	print('A ' + animal + ' is a Felidae')
print('Any of these animals is Felidae')

# 4-9
cubic = [number**3 for number in range(1,11)]
print(cubic)

# 4-11
my_pizzas = ['a_pizza' , 'b_pizza' , 'c_pizza']
friend_pizzas = my_pizzas[:]
my_pizzas.append('d_pizza')
friend_pizzas.append('e_pizzas')
print('My favorite pizzas are:')
for pizza1 in my_pizzas:
	print(pizza1)
print("My friend's favorite pizzas are:")
for pizza2 in friend_pizzas:
    print(pizza2)

# 4-13
foods = ('dumpling' , 'noodles' , 'rice' , 'beef' , 'egg')
for food in foods:
	print(food)
#foods[0] = potato
foods = ('dumpling' , 'noodles' , 'rice' , 'pork' , 'chicken')
for food in foods:
	print(food)

你可能感兴趣的:(作业)