[关闭]
@2014301020081 2016-09-25T14:31:17.000000Z 字数 1096 阅读 532

move my English name-Ian

the third housework
by Defeng Kong (2014301020081)


1.Abstract

I'll make my name move from left to right and from up to down in the sceern by the main commends'os.system('cls')'and'time.sleep(t)' of python.Of course,the loop statement'while' is also needed.

2.Backgroud

Last week, I draw my name by using python.This week,I'll make it move in the screen by using python too.

3.The Main Body

  1. from left to right
    the code:
  1. import os
  2. import time
  3. i=1
  4. n1='********'
  5. n2=' **'
  6. n3=' ** *****'
  7. n4=' ** ***** * * *'
  8. n5=' ** * * * *'
  9. n6=' ** * * * *'
  10. n7=' ** * * * *'
  11. n8=' ** * * * *'
  12. n9='******** ****** ** * **'
  13. a=' '
  14. while(i<50):
  15. print n1
  16. print n2
  17. print n3
  18. print n4
  19. print n5
  20. print n6
  21. print n7
  22. print n8
  23. print n9
  24. n1=a+n1
  25. n2=a+n2
  26. n3=a+n3
  27. n4=a+n4
  28. n5=a+n5
  29. n6=a+n6
  30. n7=a+n7
  31. n8=a+n8
  32. n9=a+n9
  33. i+=1
  34. time.sleep(0.5)
  35. os.system('cls')


2. from up to down
the code

  1. import os
  2. import time
  3. i=1
  4. n='''
  5. ********
  6. **
  7. ** *****
  8. ** ***** * * *
  9. ** * * * *
  10. ** * * * *
  11. ** * * * *
  12. ** * * * *
  13. ******** ****** ** * **
  14. '''
  15. a='''
  16. '''
  17. while(i<50):
  18. print(n)
  19. n=a+n
  20. i+=1
  21. time.sleep(0.5)
  22. os.system('cls')

run:
GIF of name

4.Conclusion

For the item from left to right,I can also use the way of making the
strings to the list.in this way,I can add the " "to the front of every elements of list more simplier.
For The second question,I can't make it by myself.

5.Thanks

Defeng Kong

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