Learn ptyon the Hrad Way

exercise 7

2017-12-29  本文已影响0人  不娶名字
# 打印字符串“Mary had a little lamb.”
print("Mary had a little lamb.")
# 打印字符串“Its fleece was white as show.”
print("Its fleece was white as {}.".format('show'))
# 打印“And every where tha Mary went.”
print("And everywhere that Mary went.")
# 使“.”号重复十遍
print("."*10)   #what'd that do?

# 接下来的11~22行是赋值
end1 = "C"
end2 = "h"
end3 = "e"
end4 = "e"
end5 = "s"
end6 = "e"
end7 = "B"
end8 = "u"
end9 = "r"
end10 = "g"
end11 = "e"
end12 = "r"

# watch end = '' at the end. try removing it to see what happens
# 我在实验下面的函数过程中并通过查找资料发现,print()函数有两个参数——sep和end参数,下面就是用到了end参数。
# print()函数中的逗号默认用空格代替,末尾默认加上换行符。其中sep是代替分隔符,end是代替末尾的换行符。
print(end1 + end2 + end3 + end5 + end6 , end = ' ')
print(end7 + end8 + end9 + end10 + end11 + end12)
  1. Go back through and write a comment on what each line does.
  2. Read each one backward or out loud to find your errors.
  3. From now on, when you make mistakes, write down on a piece of paper what kind of mistake you made.
  4. When you go to the next exercise, look at the mistakes you have made and try not to make them in this new one.
  5. Remember that everyone makes mistakes. Programmers are like magicians who fool everyone into thinking they are perfect and never wrong, but it's all an act. They make mistakes all the time.
上一篇下一篇

猜你喜欢

热点阅读