PYTHON从入门到实践:第八章答案

8.3

def make_shirt(size, word):

print ("The T-shirt's size is " + size + ", and it has printed the word '" + word + "' on it.")

make_shirt('S', 'I love Python')

make_shirt(size = 'S', word = 'I love Python')

8.4

 def make_shirt(size, word = 'I love python'):

print ("The T-shirt's size is " + size + ", and it has printed the word '" + word + "' on it.")


make_shirt('L')

make_shirt('M')

make_shirt('S',word = "Others")    

8.5

>>>def describe_city(name, country = 'China'):

    print (name + ' is in ' + country + '.')

>>>describe_city('Hangzhou')
Hangzhou is in China.
>>> describe_city('Suzhou')
Suzhou is in China.
>>> describe_city('Shanghai')
Shanghai is in China.
>>> describe_city('London', 'Britain')
London is in Britain.

你可能感兴趣的:(PYTHON从入门到实践:第八章答案)