美文网首页Learn to Code
《笨办法学Python3》练习七:更多的打印

《笨办法学Python3》练习七:更多的打印

作者: 雨开Ame | 来源:发表于2019-02-28 16:50 被阅读0次

    练习代码

    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

    1. 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)
    
    1. Read each one backward or out loud to find your errors.

    2. From now on, when you make mistakes, write down on a piece of paper what kind of mistake you made.

    3. When you go to the next exercise, look at the mistakes you have made and try not to make
      them in this new one.

    4. 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.

    相关文章

      网友评论

        本文标题:《笨办法学Python3》练习七:更多的打印

        本文链接:https://www.haomeiwen.com/subject/xakkuqtx.html