[关闭]
@Zemel-Yang 2016-09-26T01:38:06.000000Z 字数 1247 阅读 799

All levels

python homework

Author: Zongmeng Yang
Student number: 2014301020092


Abstruct

  1. Design a programe to make my Eglish name moved on the screen.

    Tips:

    • We can use this code to clean the screen.
    1. import os
    2. i = os.system('cls')
    • Words can be moved by adding space before each line.
    1. print(" ###")
    2. print(" # ")
    3. print(" # ")
    4. print(" # ")
    5. print(" ###")
  2. Draw something you want (such as rocket, matchstick man) in a 80×80 bitmap and make it rotate.

    Tips:

  3. Make strings into lists.


    a = "test"
    l = list(a)

  4. Make lists into strings.

    1. a = "".join(l)

Content

1.L1

I use a loop statement to make it work. It will add some space in each loop and then clean the screen.
[Code][1]
  1. import os
  2. import time
  3. i=os.system('cls')
  4. a0 = "##### ##### # # ##### # # # ###### # # ######"
  5. a1 = " # # ## ## # # # # # # # # # # "
  6. a2 = " # ##### # # # # ##### # # ###### # # # # ###"
  7. a3 = " # # # # # # # # # # # # # # # #"
  8. a4 = "##### ##### # # # ##### ##### # # # # # ######"
  9. b = 0
  10. while b < 11:
  11. print (' '*b+a0)
  12. print (' '*b+a1)
  13. print (' '*b+a2)
  14. print (' '*b+a3)
  15. print (' '*b+a4)
  16. time.sleep(1)
  17. i=os.system('cls')
  18. b += 1

Result
disadvantage: It can't move on the screen forever

2. L2

Code

  1. import time
  2. import os
  3. a=(" ############\n")
  4. b=(" ### ###\n")
  5. c=(" #### \n")
  6. d=("##################\n")
  7. e=(" ## \n")
  8. f=("##### ## ######\n")
  9. k=(" ######### ##\n")
  10. g=3*a+6*b+2*c+2*d+2*c+2*a+4*b
  11. h=3*e+3*f+4*k+3*f+3*e
  12. i=4*b+2*a+2*c+2*d+2*c+6*b+3*a
  13. j=3*e+3*f+4*k+3*f+3*e
  14. li=[g,h,i,j]
  15. i=0
  16. while i<20:
  17. print(li[i%4])
  18. time.sleep(1)
  19. i=i+1
  20. os.system('cls')

Result
Thanks To:
Shengyong Hu

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注