加入收藏 | 设为首页 | 会员中心 | 我要投稿 济南站长网 (https://www.0531zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > 建站资源 > 优化 > 正文

分享几款由“Python”语言编写的“有趣、恶搞、好玩”的程序代码

发布时间:2019-01-30 22:23:29 所属栏目:优化 来源:信息安全我来讲你来听
导读:副标题#e# 为提高大家对Python编程语言的学习兴趣,今天给大家分享几款有趣的Python程序代码,感兴趣的小伙伴可以跟着学习借鉴哦! 分享一:啥是佩奇?让Python语言告诉你 用Python代码创作一副佩奇: #coding:utf-8 importturtleast t.pensize(4) t.hideturt
副标题[/!--empirenews.page--]

为提高大家对“Python”编程语言的学习兴趣,今天给大家分享几款有趣的Python程序代码,感兴趣的小伙伴可以跟着学习借鉴哦!

分享一:"啥是佩奇?"让Python语言告诉你

"啥是佩奇?"让Python语言告诉你

用Python代码创作一副佩奇:

  1. # coding:utf-8 
  2. import turtle as t 
  3.  
  4. t.pensize(4) 
  5. t.hideturtle() 
  6. t.colormode(255) 
  7. t.color((255,155,192),"pink") 
  8. t.setup(840,500) 
  9. t.speed(10) 
  10.  
  11. #鼻子 
  12. t.pu() 
  13. t.goto(-100,100) 
  14. t.pd() 
  15. t.seth(-30) 
  16. t.begin_fill() 
  17. a=0.4 
  18. for i in range(120): 
  19. if 0<=i<30 or 60<=i<90: 
  20. aa=a+0.08 
  21. t.lt(3) #向左转3度 
  22. t.fd(a) #向前走a的步长 
  23. else: 
  24. aa=a-0.08 
  25. t.lt(3) 
  26. t.fd(a) 
  27. t.end_fill() 
  28.  
  29. t.pu() 
  30. t.seth(90) 
  31. t.fd(25) 
  32. t.seth(0) 
  33. t.fd(10) 
  34. t.pd() 
  35. t.pencolor(255,155,192) 
  36. t.seth(10) 
  37. t.begin_fill() 
  38. t.circle(5) 
  39. t.color(160,82,45) 
  40. t.end_fill() 
  41.  
  42. t.pu() 
  43. t.seth(0) 
  44. t.fd(20) 
  45. t.pd() 
  46. t.pencolor(255,155,192) 
  47. t.seth(10) 
  48. t.begin_fill() 
  49. t.circle(5) 
  50. t.color(160,82,45) 
  51. t.end_fill() 
  52.  
  53. #头 
  54. t.color((255,155,192),"pink") 
  55. t.pu() 
  56. t.seth(90) 
  57. t.fd(41) 
  58. t.seth(0) 
  59. t.fd(0) 
  60. t.pd() 
  61. t.begin_fill() 
  62. t.seth(180) 
  63. t.circle(300,-30) 
  64. t.circle(100,-60) 
  65. t.circle(80,-100) 
  66. t.circle(150,-20) 
  67. t.circle(60,-95) 
  68. t.seth(161) 
  69. t.circle(-300,15) 
  70. t.pu() 
  71. t.goto(-100,100) 
  72. t.pd() 
  73. t.seth(-30) 
  74. a=0.4 
  75. for i in range(60): 
  76. if 0<=i<30 or 60<=i<90: 
  77. aa=a+0.08 
  78. t.lt(3) #向左转3度 
  79. t.fd(a) #向前走a的步长 
  80. else: 
  81. aa=a-0.08 
  82. t.lt(3) 
  83. t.fd(a) 
  84. t.end_fill() 
  85.  
  86. #耳朵 
  87. t.color((255,155,192),"pink") 
  88. t.pu() 
  89. t.seth(90) 
  90. t.fd(-7) 
  91. t.seth(0) 
  92. t.fd(70) 
  93. t.pd() 
  94. t.begin_fill() 
  95. t.seth(100) 
  96. t.circle(-50,50) 
  97. t.circle(-10,120) 
  98. t.circle(-50,54) 
  99. t.end_fill() 
  100.  
  101. t.pu() 
  102. t.seth(90) 
  103. t.fd(-12) 
  104. t.seth(0) 
  105. t.fd(30) 
  106. t.pd() 
  107. t.begin_fill() 
  108. t.seth(100) 
  109. t.circle(-50,50) 
  110. t.circle(-10,120) 
  111. t.circle(-50,56) 
  112. t.end_fill() 
  113.  
  114. #眼睛 
  115. t.color((255,155,192),"white") 
  116. t.pu() 
  117. t.seth(90) 
  118. t.fd(-20) 
  119. t.seth(0) 
  120. t.fd(-95) 
  121. t.pd() 
  122. t.begin_fill() 
  123. t.circle(15) 
  124. t.end_fill() 
  125.  
  126. t.color("black") 
  127. t.pu() 
  128. t.seth(90) 
  129. t.fd(12) 
  130. t.seth(0) 
  131. t.fd(-3) 
  132. t.pd() 
  133. t.begin_fill() 
  134. t.circle(3) 
  135. t.end_fill() 
  136.  
  137. t.color((255,155,192),"white") 
  138. t.pu() 
  139. t.seth(90) 
  140. t.fd(-25) 
  141. t.seth(0) 
  142. t.fd(40) 
  143. t.pd() 
  144. t.begin_fill() 
  145. t.circle(15) 
  146. t.end_fill() 
  147.  
  148. t.color("black") 
  149. t.pu() 
  150. t.seth(90) 
  151. t.fd(12) 
  152. t.seth(0) 
  153. t.fd(-3) 
  154. t.pd() 
  155. t.begin_fill() 
  156. t.circle(3) 
  157. t.end_fill() 
  158.  
  159. #腮 
  160. t.color((255,155,192)) 
  161. t.pu() 
  162. t.seth(90) 
  163. t.fd(-95) 
  164. t.seth(0) 
  165. t.fd(65) 
  166. t.pd() 
  167. t.begin_fill() 
  168. t.circle(30) 
  169. t.end_fill() 
  170.  
  171. #嘴 
  172. t.color(239,69,19) 
  173. t.pu() 
  174. t.seth(90) 
  175. t.fd(15) 
  176. t.seth(0) 
  177. t.fd(-100) 
  178. t.pd() 
  179. t.seth(-80) 
  180. t.circle(30,40) 
  181. t.circle(40,80) 
  182.  
  183. #身体 
  184. t.color("red",(255,99,71)) 
  185. t.pu() 
  186. t.seth(90) 
  187. t.fd(-20) 
  188. t.seth(0) 
  189. t.fd(-78) 
  190. t.pd() 
  191. t.begin_fill() 
  192. t.seth(-130) 
  193. t.circle(100,10) 
  194. t.circle(300,30) 
  195. t.seth(0) 
  196. t.fd(230) 
  197. t.seth(90) 
  198. t.circle(300,30) 
  199. t.circle(100,3) 
  200. t.color((255,155,192),(255,100,100)) 
  201. t.seth(-135) 
  202. t.circle(-80,63) 
  203. t.circle(-150,24) 
  204. t.end_fill() 
  205.  
  206. #手 
  207. t.color((255,155,192)) 
  208. t.pu() 
  209. t.seth(90) 
  210. t.fd(-40) 
  211. t.seth(0) 
  212. t.fd(-27) 
  213. t.pd() 
  214. t.seth(-160) 
  215. t.circle(300,15) 
  216. t.pu() 
  217. t.seth(90) 
  218. t.fd(15) 
  219. t.seth(0) 
  220. t.fd(0) 
  221. t.pd() 
  222. t.seth(-10) 
  223. t.circle(-20,90) 
  224.  
  225. t.pu() 
  226. t.seth(90) 
  227. t.fd(30) 
  228. t.seth(0) 
  229. t.fd(237) 
  230. t.pd() 
  231. t.seth(-20) 
  232. t.circle(-300,15) 
  233. t.pu() 
  234. t.seth(90) 
  235. t.fd(20) 
  236. t.seth(0) 
  237. t.fd(0) 
  238. t.pd() 
  239. t.seth(-170) 
  240. t.circle(20,90) 
  241.  
  242. #脚 
  243. t.pensize(10) 
  244. t.color((240,128,128)) 
  245. t.pu() 
  246. t.seth(90) 
  247. t.fd(-75) 
  248. t.seth(0) 
  249. t.fd(-180) 
  250. t.pd() 
  251. t.seth(-90) 
  252. t.fd(40) 
  253. t.seth(-180) 
  254. t.color("black") 
  255. t.pensize(15) 
  256. t.fd(20) 
  257.  
  258. t.pensize(10) 
  259. t.color((240,128,128)) 
  260. t.pu() 
  261. t.seth(90) 
  262. t.fd(40) 
  263. t.seth(0) 
  264. t.fd(90) 
  265. t.pd() 
  266. t.seth(-90) 
  267. t.fd(40) 
  268. t.seth(-180) 
  269. t.color("black") 
  270. t.pensize(15) 
  271. t.fd(20) 
  272.  
  273. #尾巴 
  274. t.pensize(4) 
  275. t.color((255,155,192)) 
  276. t.pu() 
  277. t.seth(90) 
  278. t.fd(70) 
  279. t.seth(0) 
  280. t.fd(95) 
  281. t.pd() 
  282. t.seth(0) 
  283. t.circle(70,20) 
  284. t.circle(10,330) 
  285. t.circle(70,30) 
  286. t.done() 

(编辑:济南站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!