练习代码
print("Mary had a little lamb.")
print("Its fleece was white as {}.".format('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 end = ' ' at the end. try removing it to see what happens
print(end1 + end2 + end3 + end4 + end5 + end6, end = ' ')
print(end7 + end8 + end9 + end10 + end11 + end12)
Study Drills
- Go back through and write a comment on what each line does.
# 打印字符串
print("Mary had a little lamb.")
# 打印字符串,并使用format方法将'snow'插入到字符串中
print("Its fleece was white as {}.".format('snow'))
# 打印。。。
print("And everywhere that Mary went.")
# 使用'*'打印10个打印'.'
print("." * 10) # what'd that do?
# 声明12个变量,分别存储一个字符
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
# 打印end1到end6连接起来的字符串,print的end参数改为空格(默认是换行)
print(end1 + end2 + end3 + end4 + end5 + end6, end = ' ')
# 打印end7到end12连接起来的字符串
print(end7 + end8 + end9 + end10 + end11 + end12)
-
Read each one backward or out loud to find your errors.
-
From now on, when you make mistakes, write down on a piece of paper what kind of mistake you made.
-
When you go to the next exercise, look at the mistakes you have made and try not to make
them in this new one. -
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.
网友评论