python教材第三章答案_《Python编程:从入门到实践》第三章 列表简介 习题答案...

#3.1

names=['lpr','tjl','gnl','by','dqy'];print(names[0]);print(names[1]);print(names[2]);print(names[3]);print(names[4]);#3.2

print(names[0]+",Hello!");print(names[1]+",Hello!");print(names[2]+",Hello!");print(names[3]+",Hello!");print(names[4]+",Hello!");#3.3

transport=['bike','high-way','bus','taxi','plane'];print("I would like to own a"+transport[0]);print("I would like to own a"+transport[1]);print("I would like to own a"+transport[2]);print("I would like to own a"+transport[3]);print("I would like to own a"+transport[4]);#3.4

friends=['by','xdy','lyx'];print("Hello,"+friends[0]+"! I would like to invent you to have dinner with me!");print("Hello,"+friends[1]+"! I would like to invent you to have dinner with me!");print("Hello,"+friends[2]+"! I would like to invent you to have dinner with me!");#3.5

print(friends[1]+"cannot come here for dinner!");

friends[1]='dqy';print("Hello,"+friends[0]+"! I would like to invent you to have dinner with me!");print("Hello,"+friends[1]+"! I would like to invent you to have dinner with me!");print("Hello,"+friends[2]+"! I would like to invent you to have dinner with me!");#3.6

print("Hello,my friends!I have got a bigger desk for dinner just now,let's invent more 3 fridens!");

friends.insert(0,'lpr');

friends.insert(2,'nsx');

friends.append('gj');print("Hello,"+friends[0]+"! I would like to invent you to have dinner with me!");print("Hello,"+friends[1]+"! I would like to invent you to have dinner with me!");print("Hello,"+friends[2]+"! I would like to invent you to have dinner with me!");print("Hello,"+friends[3]+"! I would like to invent you to have dinner with me!");print("Hello,"+friends[4]+"! I would like to invent you to have dinner with me!");print("Hello,"+friends[5]+"! I would like to invent you to have dinner with me!");#3.7

print("Sorry,I could only invent 2 friends for dinner!");

sorry=friends.pop();print(sorry+",I am so sorry that you can't have dinner with me tonight!");

sorry=friends.pop();print(sorry+",I am so sorry that you can't have dinner with me tonight!");

sorry=friends.pop();print(sorry+",I am so sorry that you can't have dinner with me tonight!");

sorry=friends.pop();print(sorry+",I am so sorry that you can't have dinner with me tonight!");print("-----------------------------------------");print(friends[-1]+",you can have dinner here,enjoy yourselves!");print(friends[-2]+",you can have dinner here,enjoy yourselves!");print("-----------------------------------------");delfriends[0];delfriends[0];print(friends);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值