我是靠谱客的博主 大方巨人,最近开发中收集的这篇文章主要介绍python从入门到实践习题_Python编程:从入门到实践(3.2章练习题),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

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章练习题)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(73)

评论列表共有 0 条评论

立即
投稿
返回
顶部