这个习题比较简单,设计到字符串的相加和相乘!话不多说,直接上代码:
print("Mary had a little lamb")
print("Its fleece was white as %s." %'snow')
print("And everwhere that Mary went.")
print("."*10)
end1 = "C"
end2 = "h"
end3 = "e"*2
end4 = "s"
end5 = "e"
print(end1+end2+end3+end4+end5)运行结果:
mystuff simengred$ python ex7.py
Mary had a little lamb
Its fleece was white as snow.
And everwhere that Mary went.
..........
Cheese
本文通过一个简单的Python程序演示了字符串的拼接与重复操作。利用字符串的加法和乘法特性,展示了如何将不同的字符串片段组合成完整的句子,并通过代码运行结果验证了操作的有效性。
831

被折叠的 条评论
为什么被折叠?



