Python编程 从入门到实践 练习8-3~练习8-5

8-3 T恤

# T恤
def make_shirt(size, message):
	"""概要的说明T恤的尺码和字样"""
	print("\nT-shirt size is " + size + ".")
	print("The words on the T-shirt are " + message + ".")

# 使用位置实参调用函数制作一件T恤
make_shirt('XL', 'good morning')
# 使用关键字实参调用函数
make_shirt(message = 'good morning', size = 'XL')

8-3输出

8-4 大号T恤

# 大号T恤
def make_shirt(size, message = 'I love Python'):
	"""概要的说明T恤的尺码和字样"""
	print("\nT-shirt size is " + size + ".")
	print("The words on the T-shirt are " + message + ".")

# 一件印有默认字样的大号T恤
make_shirt('L')
# 一件印有默认字样的中号T恤
make_shirt('M')
# 一件其它字样的T恤
make_shirt('S', 'I love you')

8-4输出

8-5 城市

# 城市
def describe_city(city, country = 'iceland'):
	"""显示城市所属的国家"""
	print(city.title() + " is in " + country.title())

describe_city('reykjavik')
describe_city('beijing', 'china')
describe_city(country = 'china', city = 'shanghai')

8-5输出

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值