当前位置:   article > 正文

Python编程 从入门到实践 第三章 作业参考答案_头歌python第三章答案

头歌python第三章答案

3-1 3-2 姓名 问候语

  1. names = ["书涵","剑权","泽坤"]
  2. sayhi = ",你好呀~~"
  3. for name in names:
  4. print(name)
  5. print('----------')
  6. for name in names:
  7. print(name,sayhi)
  1. ================= RESTART: D:/program/Python/print_names.py =================
  2. 书涵
  3. 剑权
  4. 泽坤
  5. ----------
  6. 书涵 ,你好呀~~
  7. 剑权 ,你好呀~~
  8. 泽坤 ,你好呀~~

3-3 自己的列表

  1. transportation =[ "on foot","by Honda motorcycle",
  2. "by bike", "by Xiaohuang"]
  3. for t in transportation:
  4. print("Well, today I want to go outside",t)
  1. ================= RESTART: D:/program/Python/print_names.py =================
  2. Well, today I want to go outside on foot
  3. Well, today I want to go outside by Honda motorcycle
  4. Well, today I want to go outside by bike
  5. Well, today I want to go outside by Xiaohuang

3-4  3-5 3-6 3-7 嘉宾名单 修改嘉宾名单 添加嘉宾名单 缩减名单

  1. invitation = ["Hawking","Turning","Knuth"]
  2. def invite():
  3. for one in invitation:
  4. print("Hi,{},could you please go dinner with me tonight?".format(one))
  5. invite() #3-4
  6. deny = invitation[0]
  7. print("{} has just left us".format(deny))
  8. invitation[0] = "Zhengning Wang"
  9. invite() #3-5
  10. print("Good news. We have found a greater table.")
  11. invitation.insert(0,"Zhengdao Li")
  12. invitation.insert(2,"Xingbei Shu")
  13. invitation.append("Jiuzhang Zhao")
  14. invite() # 3-6
  15. print("I'm very sorry that I cannot invite all of you\
  16. , due to the new table's delivery.")
  17. for one in invitation[2:]:
  18. print(one,",I'm very sorry that I cannot invite all of you\
  19. , due to the new table's delivery.\n")
  20. invitation.pop(2)
  21. for one in invitation[:2]:
  22. print(one,", you are still invited. Can you come over?")
  23. del invitation[0]
  24. del invitation[0]
  25. invite()
  1. ================= RESTART: D:/program/Python/print_names.py =================
  2. Hi,Hawking,could you please go dinner with me tonight?
  3. Hi,Turning,could you please go dinner with me tonight?
  4. Hi,Knuth,could you please go dinner with me tonight?
  5. Hawking has just left us
  6. Hi,Zhengning Wang,could you please go dinner with me tonight?
  7. Hi,Turning,could you please go dinner with me tonight?
  8. Hi,Knuth,could you please go dinner with me tonight?
  9. Good news. We have found a greater table.
  10. Hi,Zhengdao Li,could you please go dinner with me tonight?
  11. Hi,Zhengning Wang,could you please go dinner with me tonight?
  12. Hi,Xingbei Shu,could you please go dinner with me tonight?
  13. Hi,Turning,could you please go dinner with me tonight?
  14. Hi,Knuth,could you please go dinner with me tonight?
  15. Hi,Jiuzhang Zhao,could you please go dinner with me tonight?
  16. I'm very sorry that I cannot invite all of you, due to the new table's delivery.
  17. Xingbei Shu ,I'm very sorry that I cannot invite all of you, due to the new table's delivery.
  18. Turning ,I'm very sorry that I cannot invite all of you, due to the new table's delivery.
  19. Knuth ,I'm very sorry that I cannot invite all of you, due to the new table's delivery.
  20. Jiuzhang Zhao ,I'm very sorry that I cannot invite all of you, due to the new table's delivery.
  21. Zhengdao Li , you are still invited. Can you come over?
  22. Zhengning Wang , you are still invited. Can you come over?

3-8 放眼世界

  1. places = ['Paris','New York','San Fransico','London','Silcon Valley']
  2. print("--------------------------")
  3. print(places)
  4. print("--------------------------")
  5. print(sorted(places))
  6. print("--------------------------")
  7. print(places)
  8. print("--------------------------")
  9. print(sorted(places,reverse=True))
  10. print("--------------------------")
  11. print(places)
  12. print("--------------------------")
  13. places.reverse()
  14. print(places)
  15. print("--------------------------")
  16. places.reverse()
  17. print(places)
  18. print("--------------------------")
  19. places.sort()
  20. print(places)
  21. print("--------------------------")
  22. places.sort(reverse=True)
  23. print(places)
  1. =============== RESTART: D:/program/Python/place_want_to_go.py ===============
  2. --------------------------
  3. ['Paris', 'New York', 'San Fransico', 'London', 'Silcon Valley']
  4. --------------------------
  5. ['London', 'New York', 'Paris', 'San Fransico', 'Silcon Valley']
  6. --------------------------
  7. ['Paris', 'New York', 'San Fransico', 'London', 'Silcon Valley']
  8. --------------------------
  9. ['Silcon Valley', 'San Fransico', 'Paris', 'New York', 'London']
  10. --------------------------
  11. ['Paris', 'New York', 'San Fransico', 'London', 'Silcon Valley']
  12. --------------------------
  13. ['Silcon Valley', 'London', 'San Fransico', 'New York', 'Paris']
  14. --------------------------
  15. ['Paris', 'New York', 'San Fransico', 'London', 'Silcon Valley']
  16. --------------------------
  17. ['London', 'New York', 'Paris', 'San Fransico', 'Silcon Valley']
  18. --------------------------
  19. ['Silcon Valley', 'San Fransico', 'Paris', 'New York', 'London']

太多啦,不打了。

有任何疑问请 email 280917855@qq.com 寻求帮助


声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/386822
推荐阅读
相关标签
  

闽ICP备14008679号