Ex7 More Printing

再战Printing

在 Ex7,Zed 给出的练习是继续 Printing。老Z倒是👂爽快,直说不想解释太多,就是练习手艺(The purpose is to build up your chops)。不要空过,不要粘贴!

示例代码 Ex7:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
print "Mary had a little lamb."
print "It's fleece was white as %s." % 'snow'
print "And everywhere that Mary went."
print "." * 10 # what'd that do?
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 the comma at the end. try removing it to see what happens
print end1 + end2 + end3 + end4 + end5 + end6,
print end7 + end8 + end9 + end10 + end11 + end12

代码里, Zed 提示,要注意最后逗号的作用。两种运行结果如下:

小结

Ex7 对 Ex6 中的内容加深练习。同时,引入了新的内容:逗号可以把两个 print 语句放在同一行显示。

Licensed under CC BY-NC-SA 4.0
使用 Hugo 构建
主题 StackJimmy 设计