Learn Python The Hard Way learning (7)-more print

Source: Internet
Author: User

Next, I will do more exercises. I will do it myself, and I will do it myself and run it. Do not copy and paste the exercises, or skip these exercises.
1. # -- coding: UTF-8 --
2. print "Mary had a little lamb ."
3. print "Its fleece was white as % s." % 'snow'
4. print "And everywhere that Mary went ."
5. print "," * 10 # what has been done here?
6.
7.
8. end1 = "C"
9. end2 = "h"
10. end3 = "e"
11. end4 = "e"
12. end5 = "s"
13. end6 = "e"
14. end7 = "B"
15. end8 = "u"
16. end9 = "r"
17. end10 = "g"
18. end11 = "e"
19. end12 = "r"
20.
21.
22. # Check the comma. If you remove it, check what will happen.
23. print end1 + end2 + end3 + end4 + end5 + end6,
24. print end7 + end8 + end9 + end10 + end11 + end12

Running result
Mary had a little lamb.
Its fleece was white as snow.
And everywhere that Mary went.
,,,,,,,,,,
Cheese Burger

Extra score exercise
The next few exercises share the same bonus points.
1. Write comments for each line
2. Read your code carefully and find out the error.
3. Record your errors from now on and write them on paper.
4. Check your mistakes during the next exercise to avoid further mistakes.
5. programmers and magicians hope that they will never make mistakes, but that is impossible. Everyone will make mistakes.

Next, I will do more exercises. I will do it myself, and I will do it myself and run it. Do not copy and paste the exercises, or skip these exercises.
1. # -- coding: UTF-8 --
2. print "Mary had a little lamb ."
3. print "Its fleece was white as % s." % 'snow'
4. print "And everywhere that Mary went ."
5. print "," * 10 # what has been done here?
6.
7.
8. end1 = "C"
9. end2 = "h"
10. end3 = "e"
11. end4 = "e"
12. end5 = "s"
13. end6 = "e"
14. end7 = "B"
15. end8 = "u"
16. end9 = "r"
17. end10 = "g"
18. end11 = "e"
19. end12 = "r"
20. www.2cto.com
21.
22. # Check the comma. If you remove it, check what will happen.
23. print end1 + end2 + end3 + end4 + end5 + end6,
24. print end7 + end8 + end9 + end10 + end11 + end12

Running result
Mary had a little lamb.
Its fleece was white as snow.
And everywhere that Mary went.
,,,,,,,,,,
Cheese Burger

Extra score exercise
The next few exercises share the same bonus points.
1. Write comments for each line
2. Read your code carefully and find out the error.
3. Record your errors from now on and write them on paper.
4. Check your mistakes during the next exercise to avoid further mistakes.
5. programmers and magicians hope that they will never make mistakes, but that is impossible. Everyone will make mistakes.

Author: lixiang0522

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.