练习7--打印打印

Posted luoxun

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了练习7--打印打印相关的知识,希望对你有一定的参考价值。

1 注释:写注释是为了帮助理解代码里面比较难得一部分内容,不是没一行代码都需要写注释

2 字符串创建:单引号双引号都可以,但在python中,比较短的字符串的创建一般用单引号

3 代码:

  1. print("Mary had a little lamb.") # 输出“玛丽有一只小羊羔”
  2. print("Its fleece was white as {}.".format(‘snow‘)) # 输出“它的羊毛洁白如雪”
  3. print("And everywhere that Mary went.") # 输出“玛丽去过的每一个地方”
  4. print("." * 10) # what that do? 字符“.”被输出了10次,表示省略号
  5. end1 = "c" # 定义了一个字符串变量“end1”,它的值是字符“c”
  6. end2 = "h"
  7. end3 = "e"
  8. end4 = "e"
  9. end5 = "s"
  10. end6 = "e"
  11. end7 = "B"
  12. end8 = "u"
  13. end9 = "r"
  14. end10 = "g"
  15. end11 = "e"
  16. end12 = "r"
  17. # watch that comma at the end. try removing it to see what h
  18. print(end1 + end2 + end3 + end4 + end5 + end6,end=‘‘) # 输出一个字符串cheese芝士
  19. print(end7 + end8 + end9 + end10 + end11 +end12) # 输出一个字符串Burger汉堡

4 运行结果

  • PS E:3_work4_python2_code2_LearnPythonTheHardWay> python ex7.py
  • Mary had a little lamb.
  • Its fleece was white as snow.
  • And everywhere that Mary went.
  • ..........
  • cheeseBurger

以上是关于练习7--打印打印的主要内容,如果未能解决你的问题,请参考以下文章

练习789:打印,打印,打印

习题 7: 更多打印

7-8----7-10练习

蓝桥杯练习系统历届试题 横向打印二叉树

for循环练习题-使用嵌套循环,按照下面的格式打印字母。

for循环练习题-使用嵌套循环,按照下面的格式打印字母。