任务六 时长:

啥是佩奇代码复现

参考链接:https://mp.weixin.qq.com/s/whtJOrlegpWzgisYJabxOg

画一只佩奇:

代码:

  1. from turtle import *
  2. def nose(x,y):#鼻子
  3. penup()#提起笔
  4. goto(x,y)#定位
  5. pendown()#落笔,开始画
  6. setheading(-30)#将乌龟的方向设置为to_angle/为数字(0-东、90-北、180-西、270-南)
  7. begin_fill()#准备开始填充图形
  8. a=0.4
  9. for i in range(120):
  10. if 0<=i<30 or 60<=i<90:
  11. a=a+0.08
  12. left(3) #向左转3度
  13. forward(a) #向前走a的步长
  14. else:
  15. a=a-0.08
  16. left(3)
  17. forward(a)
  18. end_fill()#填充完成
  19. penup()
  20. setheading(90)
  21. forward(25)
  22. setheading(0)
  23. forward(10)
  24. pendown()
  25. pencolor(255,155,192)#画笔颜色
  26. setheading(10)
  27. begin_fill()
  28. circle(5)
  29. color(160,82,45)#返回或设置pencolorfillcolor
  30. end_fill()
  31.  
  32. penup()
  33. setheading(0)
  34. forward(20)
  35. pendown()
  36. pencolor(255,155,192)
  37. setheading(10)
  38. begin_fill()
  39. circle(5)
  40. color(160,82,45)
  41. end_fill()
  42.  
  43. def head(x,y):#头
  44. color((255,155,192),"pink")
  45. penup()
  46. goto(x,y)
  47. setheading(0)
  48. pendown()
  49. begin_fill()
  50. setheading(180)
  51. circle(300,-30)
  52. circle(100,-60)
  53. circle(80,-100)
  54. circle(150,-20)
  55. circle(60,-95)
  56. setheading(161)
  57. circle(-300,15)
  58. penup()
  59. goto(-100,100)
  60. pendown()
  61. setheading(-30)
  62. a=0.4
  63. for i in range(60):
  64. if 0<=i<30 or 60<=i<90:
  65. a=a+0.08
  66. lt(3) #向左转3度
  67. fd(a) #向前走a的步长
  68. else:
  69. a=a-0.08
  70. lt(3)
  71. fd(a)
  72. end_fill()
  73. def ears(x,y):
  74. color((255,155,192),"pink")
  75. penup()
  76. goto(x,y)
  77. pendown()
  78. begin_fill()
  79. setheading(100)
  80. circle(-50,50)
  81. circle(-10,120)
  82. circle(-50,54)
  83. end_fill()
  84.  
  85. penup()
  86. setheading(90)
  87. forward(-12)
  88. setheading(0)
  89. forward(30)
  90. pendown()
  91. begin_fill()
  92. setheading(100)
  93. circle(-50,50)
  94. circle(-10,120)
  95. circle(-50,56)
  96. end_fill()
  97.  
  98. def eyes(x,y):
  99. color((255,155,192),"white")
  100. penup()
  101. setheading(90)
  102. forward(-20)
  103. setheading(0)
  104. forward(-95)
  105. pendown()
  106. begin_fill()
  107. circle(15)
  108. end_fill()
  109.  
  110. color("black")
  111. penup()
  112. setheading(90)
  113. forward(12)
  114. setheading(0)
  115. forward(-3)
  116. pendown()
  117. begin_fill()
  118. circle(3)
  119. end_fill()
  120.  
  121. color((255,155,192),"white")
  122. penup()
  123. seth(90)
  124. forward(-25)
  125. seth(0)
  126. forward(40)
  127. pendown()
  128. begin_fill()
  129. circle(15)
  130. end_fill()
  131.  
  132. color("black")
  133. penup()
  134. setheading(90)
  135. forward(12)
  136. setheading(0)
  137. forward(-3)
  138. pendown()
  139. begin_fill()
  140. circle(3)
  141. end_fill()
  142.  
  143. def cheek(x,y):
  144. color((255,155,192))
  145. penup()
  146. goto(x,y)
  147. pendown()
  148. setheading(0)
  149. begin_fill()
  150. circle(30)
  151. end_fill()
  152.  
  153. def mouth(x,y):
  154. color(239,69,19)
  155. penup()
  156. goto(x,y)
  157. pendown()
  158. setheading(-80)
  159. circle(30,40)
  160. circle(40,80)
  161.  
  162. def body(x,y):
  163. color("red",(255,99,71))
  164. penup()
  165. goto(x,y)
  166. pendown()
  167. begin_fill()
  168. setheading(-130)
  169. circle(100,10)
  170. circle(300,30)
  171. setheading(0)
  172. forward(230)
  173. setheading(90)
  174. circle(300,30)
  175. circle(100,3)
  176. color((255,155,192),(255,100,100))
  177. setheading(-135)
  178. circle(-80,63)
  179. circle(-150,24)
  180. end_fill()
  181.  
  182. def hands(x,y):
  183. color((255,155,192))
  184. penup()
  185. goto(x,y)
  186. pendown()
  187. setheading(-160)
  188. circle(300,15)
  189. penup()
  190. setheading(90)
  191. forward(15)
  192. setheading(0)
  193. forward(0)
  194. pendown()
  195. setheading(-10)
  196. circle(-20,90)
  197.  
  198. penup()
  199. setheading(90)
  200. forward(30)
  201. setheading(0)
  202. forward(237)
  203. pendown()
  204. setheading(-20)
  205. circle(-300,15)
  206. penup()
  207. setheading(90)
  208. forward(20)
  209. setheading(0)
  210. forward(0)
  211. pendown()
  212. setheading(-170)
  213. circle(20,90)
  214.  
  215. def foot(x,y):
  216. pensize(10)
  217. color((240,128,128))
  218. penup()
  219. goto(x,y)
  220. pendown()
  221. setheading(-90)
  222. forward(40)
  223. setheading(-180)
  224. color("black")
  225. pensize(15)
  226. fd(20)
  227.  
  228. pensize(10)
  229. color((240,128,128))
  230. penup()
  231. setheading(90)
  232. forward(40)
  233. setheading(0)
  234. forward(90)
  235. pendown()
  236. setheading(-90)
  237. forward(40)
  238. setheading(-180)
  239. color("black")
  240. pensize(15)
  241. fd(20)
  242.  
  243. def tail(x,y):
  244. pensize(4)
  245. color((255,155,192))
  246. penup()
  247. goto(x,y)
  248. pendown()
  249. seth(0)
  250. circle(70,20)
  251. circle(10,330)
  252. circle(70,30)
  253. def setting(): #参数设置
  254. pensize(4)
  255. hideturtle() #使乌龟无形(隐藏)
  256. colormode(255) #将其设置为1.0或255.随后 颜色三元组的r,g,b值必须在0 .. cmode范围内
  257. color((255,155,192),"pink")
  258. setup(840,500)
  259. speed(10)
  260. def main():
  261. setting() #画布、画笔设置
  262. nose(-100,100) #鼻子
  263. head(-69,167) #头
  264. ears(0,160) #耳朵
  265. eyes(0,140) #眼睛
  266. cheek(80,10) #腮
  267. mouth(-20,30) #嘴
  268. body(-32,-8) #身体
  269. hands(-56,-45) #手
  270. foot(2,-177) #脚
  271. tail(148,-155) #尾巴
  272. done()
  273.  
  274. if __name__ == '__main__':
  275. main()

效果图:

python基础训练营06的更多相关文章

  1. python基础训练营01

    一.基础讲解: 1.1 文件末尾的.py后缀,指出这个文件,是一个python文件,因此,系统将使用python解释器来运行该文件,确定文件中每一个单词的含义. 1.2 python编辑/运行方法: ...

  2. python 基础篇 06 编码 以及小知识点补充

    本节主要内容: 1. is和==的区别2. 编码的问题 ⼀. is和==的区别1. id()通过id()我们可以查看到⼀个变量表⽰的值在内存中的地址 注  ----<<<在pytho ...

  3. python基础训练营05

    任务五 时长:2天 1.file a.打开文件方式(读写两种方式) b.文件对象的操作方法 c.学习对excel及csv文件进行操作 2.os模块 3.datetime模块 4.类和对象 5.正则表达 ...

  4. python基础训练营04-函数

    任务四  函数的关键字 函数的定义 函数参数与作用域 函数返回值 一.函数的关键字: def 二.函数的定义: 在Python中,定义一个函数要使用def语句,依次写出函数名.括号.括号中的参数和冒号 ...

  5. python基础训练营03——字典、集合、判断、循环

    一.字典dict: 相比列表list而言,列表list像一本书,如果要查书中的某一个内容,需要把书从前往后翻一遍,直到找到想要获取的东西:而字典dict,就像现实中的字典一样,通过查找特定的字或者词( ...

  6. python基础训练营02

    任务二 时长:2天 1. 列表 a. 标志 b. 基本操作(创建,append( ),pop( ) ,del( ), 拷贝) c. 列表相关方法 2. 元组 a. 标志 b. 基本操作(创建及不可变性 ...

  7. 零基础学Python-第二章 :Python基础语法-06.变量的定义和常用操作

    网络带宽计算器的原理 输出的内容用print 引入变量,在前面写一个变量,是一个有意义的单词.把123这个数值赋值给变量a 下面的代码可读性 要比上面高很多. 变量其他需要掌握的知识点 一般这样是用做 ...

  8. Python基础:06条件和循环

    1:条件表达式(三元操作符) Python 在很长的一段时间里没有条件表达式(C ? X : Y), 或称三元运算符.人们试着用 and 和 or 来模拟它, 但大多都是错误的. 根据 FAQ , 正 ...

  9. python基础——访问限制

    python基础——访问限制 在Class内部,可以有属性和方法,而外部代码可以通过直接调用实例变量的方法来操作数据,这样,就隐藏了内部的复杂逻辑. 但是,从前面Student类的定义来看,外部代码还 ...

随机推荐

  1. java GZIP 压缩数据

    package com.cjonline.foundation.cpe.action; import java.io.ByteArrayInputStream; import java.io.Byte ...

  2. Python 学习笔记(五)常用函数

    Python内建函数 四舍五入: round() 绝对值: abs() >>> round(1.543,2) 保留两位小数,四舍五入为1.54 1.54 >>> r ...

  3. 菜鸟笔记 -- Chapter 6.2.3 成员变量

    6.2.3  成员变量 在Java中对象的属性也称为成员变量[也叫字段].成员变量的类型可以设置为Java中合法的数据类型,其实成员变量就是普通的变量,可以为它设置初始值,也可以不设置初始值,如果不设 ...

  4. TCP套接字

    端口的概念 每个电脑一根网线,但是你挂着QQ的同时还可以浏览网页.两个不同应用的数据在同一根网线里是如何传输的呢?根据七层互联网模型,这个功能由运输层(TCP是运输层主要协议)实现.怎么实现呢,在网络 ...

  5. js对URL的相关操作集锦

    1.location.href..... (1)self.loction.href="/url" window.location.href="/url"    ...

  6. js的事件流你真的弄明白了吗?

    当浏览器发展到第四代时候,浏览器开发团队遇到了一个有意思的问题:页面的哪一部分会拥有某个特地的事件?要明白这个问题问的是什么,可以想象画在纸上的一组同心圆,如果你把手指放在圆心上,那么你的手指指向的不 ...

  7. 自定义组件v-model的实质性理解

    用了几个月Vue一直很纠结自定义组件的v-model实现,最近开始学习React时,React中受控组件与状态提升的理念与v-model不谋而合. 转载请注明地址: https://www.cnblo ...

  8. 因为之前完全没有接触过Spring,所以准备先把spring实战看完再落实项目

    因为之前完全没有接触过Spring,所以准备先把spring实战看完再落实项目

  9. 利用JQUERY实现多个AJAX请求等待

    利用JQUERY实现多个AJAX请求等待 li {list-style-type:decimal;}.wiz-editor-body ol.wiz-list-level2 > li {list- ...

  10. vue入门——基本概念

    1. 挂载点,模板,实例的关系? 首先附上一个基本demo: <!DOCTYPE html> <html lang="en"> <head> & ...