任务六 时长:

啥是佩奇代码复现

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

画一只佩奇:

代码:

from turtle import *
def nose(x,y):#鼻子
penup()#提起笔
goto(x,y)#定位
pendown()#落笔,开始画
setheading(-30)#将乌龟的方向设置为to_angle/为数字(0-东、90-北、180-西、270-南)
begin_fill()#准备开始填充图形
a=0.4
for i in range(120):
if 0<=i<30 or 60<=i<90:
a=a+0.08
left(3) #向左转3度
forward(a) #向前走a的步长
else:
a=a-0.08
left(3)
forward(a)
end_fill()#填充完成
penup()
setheading(90)
forward(25)
setheading(0)
forward(10)
pendown()
pencolor(255,155,192)#画笔颜色
setheading(10)
begin_fill()
circle(5)
color(160,82,45)#返回或设置pencolor和fillcolor
end_fill()

penup()
setheading(0)
forward(20)
pendown()
pencolor(255,155,192)
setheading(10)
begin_fill()
circle(5)
color(160,82,45)
end_fill()

def head(x,y):#头
color((255,155,192),"pink")
penup()
goto(x,y)
setheading(0)
pendown()
begin_fill()
setheading(180)
circle(300,-30)
circle(100,-60)
circle(80,-100)
circle(150,-20)
circle(60,-95)
setheading(161)
circle(-300,15)
penup()
goto(-100,100)
pendown()
setheading(-30)
a=0.4
for i in range(60):
if 0<=i<30 or 60<=i<90:
a=a+0.08
lt(3) #向左转3度
fd(a) #向前走a的步长
else:
a=a-0.08
lt(3)
fd(a)
end_fill()
def ears(x,y):
color((255,155,192),"pink")
penup()
goto(x,y)
pendown()
begin_fill()
setheading(100)
circle(-50,50)
circle(-10,120)
circle(-50,54)
end_fill()

penup()
setheading(90)
forward(-12)
setheading(0)
forward(30)
pendown()
begin_fill()
setheading(100)
circle(-50,50)
circle(-10,120)
circle(-50,56)
end_fill()

def eyes(x,y):
color((255,155,192),"white")
penup()
setheading(90)
forward(-20)
setheading(0)
forward(-95)
pendown()
begin_fill()
circle(15)
end_fill()

color("black")
penup()
setheading(90)
forward(12)
setheading(0)
forward(-3)
pendown()
begin_fill()
circle(3)
end_fill()

color((255,155,192),"white")
penup()
seth(90)
forward(-25)
seth(0)
forward(40)
pendown()
begin_fill()
circle(15)
end_fill()

color("black")
penup()
setheading(90)
forward(12)
setheading(0)
forward(-3)
pendown()
begin_fill()
circle(3)
end_fill()

def cheek(x,y):
color((255,155,192))
penup()
goto(x,y)
pendown()
setheading(0)
begin_fill()
circle(30)
end_fill()

def mouth(x,y):
color(239,69,19)
penup()
goto(x,y)
pendown()
setheading(-80)
circle(30,40)
circle(40,80)

def body(x,y):
color("red",(255,99,71))
penup()
goto(x,y)
pendown()
begin_fill()
setheading(-130)
circle(100,10)
circle(300,30)
setheading(0)
forward(230)
setheading(90)
circle(300,30)
circle(100,3)
color((255,155,192),(255,100,100))
setheading(-135)
circle(-80,63)
circle(-150,24)
end_fill()

def hands(x,y):
color((255,155,192))
penup()
goto(x,y)
pendown()
setheading(-160)
circle(300,15)
penup()
setheading(90)
forward(15)
setheading(0)
forward(0)
pendown()
setheading(-10)
circle(-20,90)

penup()
setheading(90)
forward(30)
setheading(0)
forward(237)
pendown()
setheading(-20)
circle(-300,15)
penup()
setheading(90)
forward(20)
setheading(0)
forward(0)
pendown()
setheading(-170)
circle(20,90)

def foot(x,y):
pensize(10)
color((240,128,128))
penup()
goto(x,y)
pendown()
setheading(-90)
forward(40)
setheading(-180)
color("black")
pensize(15)
fd(20)

pensize(10)
color((240,128,128))
penup()
setheading(90)
forward(40)
setheading(0)
forward(90)
pendown()
setheading(-90)
forward(40)
setheading(-180)
color("black")
pensize(15)
fd(20)

def tail(x,y):
pensize(4)
color((255,155,192))
penup()
goto(x,y)
pendown()
seth(0)
circle(70,20)
circle(10,330)
circle(70,30)
def setting(): #参数设置
pensize(4)
hideturtle() #使乌龟无形(隐藏)
colormode(255) #将其设置为1.0或255.随后 颜色三元组的r,g,b值必须在0 .. cmode范围内
color((255,155,192),"pink")
setup(840,500)
speed(10)
def main():
setting() #画布、画笔设置
nose(-100,100) #鼻子
head(-69,167) #头
ears(0,160) #耳朵
eyes(0,140) #眼睛
cheek(80,10) #腮
mouth(-20,30) #嘴
body(-32,-8) #身体
hands(-56,-45) #手
foot(2,-177) #脚
tail(148,-155) #尾巴
done()

if __name__ == '__main__':
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交换两个值的三种方法 经典

    1.中间变量(在开发中常用) int c=a; a=b; b=c; System.out.println("a的值: "+a+" b的值: "+b); 2.按位 ...

  2. React Native 中组件的生命周期(转)

    概述 就像 Android 开发中的 View 一样,React Native(RN) 中的组件也有生命周期(Lifecycle).所谓生命周期,就是一个对象从开始生成到最后消亡所经历的状态,理解生命 ...

  3. 你不知道的javaScript笔记(2)

    this和对象原型 this是一个很特别的关键字,被自动定义在所有函数的作用域中 // foo.count 是0,字面理解是错误的 function foo(num) { console.log(&q ...

  4. 如何在match中使用正则表达式

    这是在实现搜索功能的时候遇到的一个问题,在搜索的场景中,会根据搜索框中输入的内容,匹配出包含搜索内容的部分.简单模拟还原使用场景: 首先定义一个遍历 value 用来接收输入的内容 var value ...

  5. [JSOI2008]最大数(线段树基础)

    题目描述 现在请求你维护一个数列,要求提供以下两种操作: 1. 查询操作. 语法:Q L 功能:查询当前数列中末尾L个数中的最大的数,并输出这个数的值. 限制: L 不超过当前数列的长度.(L > ...

  6. 大学C++程序设计教程期末复习重点

    第一章 1.cin与count的应用<iostream> 例: cin>>a; cout<<"hello"<<endl; cout& ...

  7. hdu_2588_GCD

    The greatest common divisor GCD(a,b) of two positive integers a and b,sometimes written (a,b),is the ...

  8. JSP/Servlet开发——第六章 JSP开发业务应用

    1. 大容量的数据显示的缺点: ●当数据量较多时,用户需要拖动页面才能浏览更多信息: ●数据定位不便: 2.分页显示: ●既能显示多条数据,又不需要拖动页面,是数据更加清晰直观,页面不再冗长,也不受数 ...

  9. Python序列删除重复数据

    ## 对于列表来说,若不保持原有顺序,可以直接转换为set删除重复数据 nums = [1,2,32,2,2,4,3,2,3,42] nums = list(set(nums)) print(nums ...

  10. Lavavel5.5源代码 - 并发数控制

    app('redis')->connection('default')->funnel('key000') // 每个资源最大锁定10秒自动过期,只有60个资源(并发),在3秒内获取不到锁 ...