8-12
三明治
def sandwichs(name):
print('This is your ' + name + ' sandwich')
pass
sandwichs('salad')
sandwichs('tuna')
sandwichs('tomato')
8-13
用户简介
def build_profile(first, last, **user_info):
profile= {}
profile['first_name']=first
profile['last_name']= last
for key , value in user_info.items():
profile[key]=value
pass
return profile
user_profile = build_profile('albert', 'einstein', location='princeton', field = 'phyics')
print(user_profile)
my= build_profile('Barry', 'allen', occupation = 'flash', age = '24')
print(my)
8-14
汽车
def make_car(manufacturer, model, **color_accessor):
cars={}
cars['manufacturer_name']=manufacturer
cars['model_name']=model
for key,value in color_accessor.items():
cars[key]= value
pass
return cars
car = make_car('subaru', 'outback', color= 'blue', tow_package=True)
print(car)