[关闭]
@computationalphysics-2014301020090 2016-09-25T19:04:53.000000Z 字数 2192 阅读 279

Exercise-03


Abstract

 ● Review the contents of the two courses on the main page of the cours master the grammar rules of Python and Matplotlib, and prepare for the next course.
 ● Moving your English name horizontally on the screen.
 ● Use the character to spell out what you want to draw on the 80*80 dot matrix, and let it spin, hoping to open the hole in the brain!

Background

  ● Using python preliminarily.
  ● Learning how to use matplotlib.
  ● Master the basic knowledge of computer program.

The Main Body

L1:

  1. import os
  2. import time
  3. i=os.system('cls')
  4. a0 = " # # # # "
  5. a1 = " # # # # # "
  6. a2 = "# # # # # "
  7. a3 = " # # # # "
  8. a4 = " # # #### ### #### ### # ## #### ### "
  9. a5 = " # # # # # # # # # # # # # # # # "
  10. a6 = "# # # # ####### # # # # # # # # # # # "
  11. a7 = " # # # # # # # # # # # # # # # # "
  12. a8 = " # # # ### # # ### # # ## # # ### "
  13. a9 = " # # "
  14. a10 = " # # # # "
  15. a11 = " # # # # "
  16. a12 = " ## ## "
  17. b = 0
  18. while b < 8:
  19. print (' '*b+a0)
  20. print (' '*b+a1)
  21. print (' '*b+a2)
  22. print (' '*b+a3)
  23. print (' '*b+a4)
  24. print (' '*b+a5)
  25. print (' '*b+a6)
  26. print (' '*b+a7)
  27. print (' '*b+a8)
  28. print (' '*b+a9)
  29. print (' '*b+a10)
  30. print (' '*b+a11)
  31. print (' '*b+a12)
  32. time.sleep(0.7)
  33. i=os.system('cls')
  34. b += 1

result:https://github.com/computationalphysics-N2014301020090/computational_physics_N2014301020090/blob/master/20160925_220614.gif

L2:

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

该图形像字母F,又像一个旋转的扳手。
result:https://github.com/computationalphysics-N2014301020090/computational_physics_N2014301020090/blob/master/%E6%97%8B%E8%BD%AC%E5%9B%BE%E5%BD%A2.gif

another

  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:https://github.com/computationalphysics-N2014301020090/computational_physics_N2014301020090/blob/master/%E6%97%8B%E8%BD%AC%E5%9B%BE%E5%BD%A22.gif

Conclusion

● This exercise is much more difficult than last one,but also much more interesting.
●  After this exercise,I can use python a little more adroitly,and I've learnt more grammar about python.
● Matplotlib is really useful in physics studing.
● Still unable to use Python and Matplotlib Skillfully.

Acknowledgement

Thanks to Yang Zongmeng's code Guide
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注