9.《rinting, Printing, Printing》
months = "\njan\nFed\nMar\nApr\nMay\nJun\nJul\nAug" #\n是换行
print("here are the days: ", days) #str,+变量
print("here are the months: ", months) #str, +变量
print("""
there's something going on here.
with the three double-quotes.
we'll be able to type as much as we like.
even 4 lines if we want, or 5, or 6.
""") #使用"""符号可以实现多行打印,位置不变
运行结果:
/Users/tongshiba/PycharmProjects/ex3/test9.py
Here are the days: Mon Tue Wed Thu Fri Sat Sun
Here are the months:
Feb
Mar
May
Jun
Jul
Aug
There's something going on here.
With the three double-quotes.
We'll be able to type as much as we like.
Even 4 lines if we want, or 5 ,or 6.
Study Drills练习题:
Check your work, write down your mistakes, try not to make them on the next exercise. Are you breaking
your code and then fixing it? In other words, repeat the Study Drills from Exercise 7
done
Common Student Questions常见问题:
1.Why do I get an error when I put spaces between the three double-quotes?
You have to type them like
""" and not " " ", meaning with no spaces between each one
2.What if I wanted to start the months on a new line?
You simply start the string with \n, like this:
"\nJan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"
3.Is it bad that my errors are always spelling mistakes?
Most programming errors in the beginning
(and even later) are simple spelling mistakes, typos, or getting simple things out of orde
网友评论