deffavorite_book(title):
print("My favorite book is " + title)
favorite_book("Alice in Wonderland")
My favorite book is Alice in Wonderland
习题8-4
defmake_shirt(sentense = "I love python", size = "Large"):
print("This is a " + size + " shirt, with " + sentense)
make_shirt()
make_shirt(size = "Medium")
make_shirt(sentense = "I love lily")
This is a Large shirt, with I love python
This is a Medium shirt, with I love python
This is a Large shirt, with I love lily
习题8-6
defcity_country(city, country):return city + ", " + country
print(city_country("Guangzhou", "China"))
print(city_country("Shenzhen", "China"))
print(city_country("Beijing", "China"))
Guangzhou, China
Shenzhen, China
Beijing, China
习题8-14
defmake_car(manu, model, **args):
ret = {}
ret['manu'] = manu
ret['model'] = model
for (k, v) in args.items():
ret[k] = v
return ret
print(make_car('subaru', 'outback', color='blue', tow_package=True))