7-310的整数倍:
num = int(input("Input a num:"))
if (num % 10) == 0:
print("yes")
else:
print("no")
7-4披萨配料:
a = True
while a != "quit":
a = input("wut do you want?")
if a != 'quit':
print("we will add " + a)
7-8熟食店:
sandwich_orders = ["a", 'b', 'c']
finished_sandwich = []
while sandwich_orders:
a = sandwich_orders.pop()
print("we made " + a)
finished_sandwich.extend(a)
print(finished_sandwich)
8-2喜欢的图书:
def favorite_book(book):
print("my favorite book is " + book)
favorite_book('AA')
8-4大号T恤:
def make_shirt(size,word = 'I love python'):
print("a " + size + ' tshirt is made with ' + word + ' on it')
make_shirt(size = 'large')
make_shirt(size = 'medium')
make_shirt(word='a',size='small')
8-7专辑:
def make_album(n1,n2,number = 0):
album = {'artist' : n1, 'album' : n2}
if number != 0:
album['number'] = int(number)
return album
print(make_album('a','A'))
print(make_album('b','B'))
print(make_album('c','C',2))
8-11不变的魔术师:
magicians = ["a A", 'b B', 'c C']
great_magicians = []
def make_great(list1, list2):
while list1:
a = list1.pop()
a = a + ' the great'
print(a)
list2.append(a)
print(list2)
make_great(magicians[:],great_magicians)
8-12三明治:
def sandwich(*material):
san = []
for m in material:
san.extend(m)
print(san)
sandwich('a','b','c')
sandwich('a','b')
sandwich('a')