8-3 T恤:
def make_shirt(size, words):
print("The T-shirt is "+size+" and printing "+words)
make_shirt("XXL", "Hello world")
![](https://i-blog.csdnimg.cn/blog_migrate/2b003736e78347971d2fde4e7a9539f6.png)
8-4 大号T恤:
def make_shirt(size, words = "I love python"):
print("The T-shirt is "+size+" and printed "+words)
make_shirt("L")
make_shirt("M")
make_shirt("XXL", "Hello world")
8-5 城市
def describe_city(city_name, country = "China"):
print(city_name+" is in "+country)
describe_city("Bei jing")
describe_city("Guang Zhou")
describe_city("Tokoyo","Japan")
8-6
def describe_city(city_name, country = "China"):
describe = city_name+", "+country
return describe
print(describe_city("Santiago", "Chile"))
print(describe_city("Xian", "China"))
print(describe_city("London", "U.K"))
8-7 专辑
def make_album(singer, album):
albums = {'singer':singer, 'album':album}
return albums
print(make_album("JJ","学不会"))
print(make_album("ColdPlay", "Fix you"))
print(make_album("Jay Zhou", "魔杰座"))
8-8 用户的专辑
def make_album(singer, album):
albums = {'singer':singer, 'album':album}
return albums
while True:
singer = input()
if singer == 'q':
break
album = input()
if album == 'q':
break
else:
print(make_album(singer,album))
8-9 魔术师
magicians = ["Jack", "Niko", "Lee"]
def printmagicians(magicians):
for magician in magicians:
print(magician)
printmagicians(magicians)
8-10 了不起的魔术师
magicians = ["Jack", "Niko", "Lee"]
def makegreat(magicians):
for i in range(3):
magicians[i] = "The great " + magicians[i]
makegreat(magicians)
def showmagicians(magicians):
for i in range(3):
print(magicians[i])
showmagicians(magicians)
8-11 不变的魔术师
magicians = ["Jack", "Niko", "Lee"]
def makegreat(magicians):
for i in range(3):
magicians[i] = "The great " + magicians[i]
return magicians
newmagi = makegreat(magicians[:])
def showmagicians(magicians):
for i in range(3):
print(magicians[i])
showmagicians(magicians)
showmagicians(newmagi)
8-12 三明治
def sandwich(*material):
print("这个三明治有:")
for a in material:
print(a)
sandwich("火腿", "生菜", "鸡蛋")
sandwich("培根", "番茄", "黄瓜")
sandwich("金枪鱼", "沙拉酱", "土豆")
8-14 汽车
def cars(car, model, **other):
acar={'maker':car, 'model':model}
for key,value in other.items():
acar[key] = value
return acar
newcar = cars('subaru', 'outback', color = 'blue', two_package = True)
print(newcar)
![](https://i-blog.csdnimg.cn/blog_migrate/4b8f5203fa6708669802b7505f146d19.png)