# 8-1 消息
def display_message(thing):
print(f"本章学习{thing}")
display_message('函数')
display_message('元组')
# 8-2 喜欢的图书
def favorite_book(title):
print(f"One of my favorite books is {title}")
favorite_book('Alice in Wonderland')
# 8-3 T恤
def make_shirt(size, title):
print(f"这件T恤的尺码是:{size}号,印有'{title}'字样")
make_shirt(size='大', title = 'I love Python')
make_shirt('大', 'I love Python')
# 8-4 大号T恤
def make_shirt(size, title):
print(f"制作一件印有字样'{title}'的{size}号T恤。")
make_shirt('大', 'I love Python')
make_shirt('中', 'I love Python')
make_shirt('小', 'I love Python')
# 8-5 城市
def describe_city(city, nation='China'):
print(f"{city} is in {nation}")
describe_city(city = 'Shanghai')
describe_city('Taiwan')
describe_city('Reykjavik', 'Iceland')
# 8-6 城市名
def city_country(city, country):
str1 = city + ', ' + country
return str1
c_c1 = city_country('Taibei', 'China')
c_c2 = city_country('Reykjavik', 'Iceland')
c_c3 = city_country('sant
《Python编程:从入门到实践》习题答案——第8章 函数
最新推荐文章于 2025-05-22 17:55:34 发布

最低0.47元/天 解锁文章
3055





