高级编程技术第三次作业

3-2 问候语

names = ['jams', 'tom', 'john']
for name in names:
	message = name.title() + ', welcome to the python world!'
	print(message)

3-4 嘉宾名单

names = ['Kobe', 'Hawking', 'Einstein', 'Liu Cixin']
for name in names:
	message = 'Hi ' + name.title() + ", I'm looking forward to your coming!"
	print(message)

3-5 修改嘉宾名单

names = ['Kobe', 'Hawking', 'Einstein', 'Liu Cixin']
for name in names:
	message = 'Hi ' + name.title() + ", I'm looking forward to your coming!"
	print(message)
print('Hawking and Einstein can not come.')
names[1] = 'Messi'
names[2] = 'Jackie Chan'
for name in names:
	message = 'Hi ' + name.title() + ", I'm looking forward to your coming!"
	print(message)

3-6 添加嘉宾

names = ['Kobe', 'Hawking', 'Einstein', 'Liu Cixin']
for name in names:
	message = 'Hi ' + name.title() + ", I'm looking forward to your coming!"
	print(message)
print('I find a bigger table.')
names.append('Messi')
names.insert(1, 'Jackie Chan')
for name in names:
	message = 'Hi ' + name.title() + ", I'm looking forward to your coming!"
	print(message)

3-7 缩减名单

names = ['Kobe', 'Hawking', 'Einstein', 'Liu Cixin']
for name in names:
	message = 'Hi ' + name.title() + ", I'm looking forward to your coming!"
	print(message)
print('I find a bigger table.')
names.append('Messi')
names.insert(1, 'Jackie Chan')
for name in names:
	message = 'Hi ' + name.title() + ", I'm looking forward to your coming!"
	print(message)
print('Sorry, I can only invite two people.')
num = len(names)
for i in range(num - 2):
	message = 'Sorry, ' + names[num - 1 - i].title()
	print(message)
	names.pop()
print(names[0] + ', please coming')
print(names[1] + ', please coming')
del names[0]
del names[0]
print(names)

3-8 放眼世界

places = ['London', 'Paris', 'Alps', 'Dao Cheng', 'New York']
print(places)
print(sorted(places))
print(places)
print(sorted(places, reverse = True))
print(places)
places.reverse()
print(places)
places.reverse()
print(places)
places.sort()
print(places)
places.sort(reverse = True)
print(places)


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值