习题7 更多打印

时间:2022-05-30 02:55:07

看了看,这个习题7应该是复习巩固,因为基本是学过的东西

上代码!

print "Mary had a little lamb."
print "Its fleece was white as %s." % 'snow' #注意snow不是变量而是字符串,变量名称是不带引号的
print "And everywhere that Mary went."
print "." * 10 #what'd that do?

end1 = "C" #end没什么含义,只是单纯的变量名称而已
end2 = "h"
end3 = "e"
end4 = "e"
end5 = "s"
end6 = "e"
end7 = "B"
end8 = "u"
end9 = "r"
end10 = "g"
end11 = "e"
end12 = "r"

# watch that comma at the end. try removing it to see that happens
print end1 + end2 + end3 + end4 + end5 + end6, #输出end1到end6的联合字符串
#如果不要逗号,那这一行会超级长,就很不美观

print end7 + end8 + end9 + end10 + end11 + end12 #输出end7到end12的联合字符串


接下来看输出结果,好吧我承认最后的cheese应该大写

习题7 更多打印


其中有个,

print "." * 10 #what'd that do?

其实就是输出了十个点点..........


最后有个问题是end6后面带了一个逗号,为的是把一行的东西分开两行写。如果不要逗号,那这一行会超级长,就很不美观

====================================================

附加习题

1见代码