概述
3-4 嘉宾名单
guests = ['jack','john','ocean']
print("Hello , "+guests[0]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[1]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[2]+" ! Can you have dinner with me this evening ?")
3-5 修改嘉宾名单
guests = ['jack','john','ocean']
print("Hello , "+guests[0]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[1]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[2]+" ! Can you have dinner with me this evening ?")
print(guests[2]+" , I'm very sorry you can't come to my dinner !")
guests[2] = 'sunny'
print("Hello , "+guests[0]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[1]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[2]+" ! Can you have dinner with me this evening ?")
3-6 添加嘉宾
guests = ['jack','john','ocean']
print("Hello , "+guests[0]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[1]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[2]+" ! Can you have dinner with me this evening ?")
print(guests[2]+" , I'm very sorry you can't come to my dinner !")
guests[2] = 'sunny'
print("Hello , "+guests[0]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[1]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[2]+" ! Can you have dinner with me this evening ?")
print("Dear friends , I found a bigger table! So , I would like to invite friends to our dinner party !")
guests.insert() = (0,'lee')
guests.insert() = (2,'evil')
guests.append() = 'ben'
print("Hello , "+guests[0]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[1]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[2]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[3]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[4]+" ! Can you have dinner with me this evening ?")
3-7 缩减名单
guests = ['jack','john','ocean']
print("Hello , "+guests[0]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[1]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[2]+" ! Can you have dinner with me this evening ?")
print(guests[2]+" , I'm very sorry you can't come to my dinner !")
guests[2] = 'sunny'
print("Hello , "+guests[0]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[1]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[2]+" ! Can you have dinner with me this evening ?")
print("Dear friends , I found a bigger table! So , I would like to invite friends to our dinner party !")
guests.insert() = (0,'lee')
guests.insert() = (2,'evil')
guests.append() = 'ben'
print("Hello , "+guests[0]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[1]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[2]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[3]+" ! Can you have dinner with me this evening ?")
print("Hello , "+guests[4]+" ! Can you have dinner with me this evening ?")
print("Dear friends, I just received the bad news that the new table I bought could not be delivered in time,so I can only
invite two friends to my dinner party! ")
guest = guests.pop()
print("I am very sorry,"+guest+"!")
guest = guests.pop()
print("I am very sorry,"+guest+"!")
guest = guests.pop()
print("I am very sorry,"+guest+"!")
print(guests[0]+", you are still the guest of my dinner party. I hope we can have a good evening together!")
print(guests[1]+", you are still the guest of my dinner party. I hope we can have a good evening together!")
del guests[0]
del guests[0]
print(guests)
最后
以上就是大方巨人为你收集整理的python从入门到实践习题_Python编程:从入门到实践(3.2章练习题)的全部内容,希望文章能够帮你解决python从入门到实践习题_Python编程:从入门到实践(3.2章练习题)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复