#8-2
print('#8-2')
def favorite_book(book):
print('One of my favorite book is ' + book.title())
favorite_book('The Kite Runner')
#8-3
print('#8-3')
def make_shirt(size = 2, message = 'Love'):
print('The size of T-shirt is ' + str(size) + ' and the message is ' + message)
make_shirt()
make_shirt(1,'Hate')
#8-4
print('#8-4')
def make_shirt(size = 2, message = 'I Love Python'):
print('The size of T-shirt is ' + str(size) + ' and the message is ' + message)
make_shirt(1)
make_shirt(45,'Hate')
#8-5
print('#8-5')
def describe_city(city = 'Guangdong', country = 'Guangzhou'):
print(city + ' is in ' + country)
describe_city()
describe_city('Shantou')
describe_city('Xiamen','Fujian')
输出:
G:\>python x.py
#8-2
One of my favorite book is The Kite Runner
#8-3
The size of T-shirt is 2 and the message is Love
The size of T-shirt is 1 and the message is Hate
#8-4
The size of T-shirt is 1 and the message is I Love Python
The size of T-shirt is 45 and the message is Hate
#8-5
Guangdong is in Guangzhou
Shantou is in Guangzhou
Xiamen is in Fujian
G:\>