python基础训练营06
任务六 时长:
啥是佩奇代码复现
参考链接: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的更多相关文章
- python基础训练营01
一.基础讲解: 1.1 文件末尾的.py后缀,指出这个文件,是一个python文件,因此,系统将使用python解释器来运行该文件,确定文件中每一个单词的含义. 1.2 python编辑/运行方法: ...
- python 基础篇 06 编码 以及小知识点补充
本节主要内容: 1. is和==的区别2. 编码的问题 ⼀. is和==的区别1. id()通过id()我们可以查看到⼀个变量表⽰的值在内存中的地址 注 ----<<<在pytho ...
- python基础训练营05
任务五 时长:2天 1.file a.打开文件方式(读写两种方式) b.文件对象的操作方法 c.学习对excel及csv文件进行操作 2.os模块 3.datetime模块 4.类和对象 5.正则表达 ...
- python基础训练营04-函数
任务四 函数的关键字 函数的定义 函数参数与作用域 函数返回值 一.函数的关键字: def 二.函数的定义: 在Python中,定义一个函数要使用def语句,依次写出函数名.括号.括号中的参数和冒号 ...
- python基础训练营03——字典、集合、判断、循环
一.字典dict: 相比列表list而言,列表list像一本书,如果要查书中的某一个内容,需要把书从前往后翻一遍,直到找到想要获取的东西:而字典dict,就像现实中的字典一样,通过查找特定的字或者词( ...
- python基础训练营02
任务二 时长:2天 1. 列表 a. 标志 b. 基本操作(创建,append( ),pop( ) ,del( ), 拷贝) c. 列表相关方法 2. 元组 a. 标志 b. 基本操作(创建及不可变性 ...
- 零基础学Python-第二章 :Python基础语法-06.变量的定义和常用操作
网络带宽计算器的原理 输出的内容用print 引入变量,在前面写一个变量,是一个有意义的单词.把123这个数值赋值给变量a 下面的代码可读性 要比上面高很多. 变量其他需要掌握的知识点 一般这样是用做 ...
- Python基础:06条件和循环
1:条件表达式(三元操作符) Python 在很长的一段时间里没有条件表达式(C ? X : Y), 或称三元运算符.人们试着用 and 和 or 来模拟它, 但大多都是错误的. 根据 FAQ , 正 ...
- python基础——访问限制
python基础——访问限制 在Class内部,可以有属性和方法,而外部代码可以通过直接调用实例变量的方法来操作数据,这样,就隐藏了内部的复杂逻辑. 但是,从前面Student类的定义来看,外部代码还 ...
随机推荐
- 根据GB2312编码表求汉字字节
java中有8种基本数据类型,byte,short,int,long,float,double,boolean byte用1个字节表示,占8比特,取值范围 负2的7次方至正2的7次方减1 二进制000 ...
- python tips(持续更新中)
python tips 可变对象与不可变对象 在python中,可变对象有数值类型(int,float),字符串(str),元组(tuple),可变对象有列表(list),字典(dict),集合(se ...
- HTML表格和表单
<table>格式: 注意:1. 合并单元格:COLSPAN(跨列)ROWSPAN(跨行) 2.cellspacing属性定义单元格之间的间距(以像素为单位). cellpadding属性 ...
- spring入门(三) 使用spring mvc
1.建立project / module 新建空的project:springMvcStudy 新建module:type maven-webapp,名字mvcStudy 2.为module设置Sou ...
- 构建高可靠hadoop集群之4-保全模式
本文主要翻译自http://hadoop.apache.org/docs/r2.8.0/hadoop-project-dist/hadoop-common/SecureMode.html 译注:之所以 ...
- 部署node api的二三事
当接到node开发node api的时候,我就想用docker来部署,众所周知,node的版本更新迭代很快.很多以前需要babel后才能采用的方法正在不断被node 原生的支持.如果随便更换生产服务器 ...
- ECSHOP和SHOPEX快递单号查询申通插件V8.6专版
发布ECSHOP说明: ECSHOP快递物流单号查询插件特色 本ECSHOP快递物流单号跟踪插件提供国内外近2000家快递物流订单单号查询服务例如申通快递.顺丰快递.圆通快递.EMS快递.汇通快递.宅 ...
- JS 定时器,定时调用PHP
$(function() { var voiceplay=function(){ var site = location.href.split('_cms')[0] + '_cms/'; $.ajax ...
- SHELL里执行HIVE导出文件处理成CSV文件
#!/bin/bash #用途: #.当前目录的txt文件批量转csv #.制表符转逗号分隔符 #.NULL去除 #.删除WARN警告 for i in `ls ./*.txt` do sed -e ...
- 对URI的理解
在了解RESTful api的设计规范的时候,遇到了一个问题,就是uri和url有什关系,有什么区别,所以就在这里记录一下. URI(Uniform Resource Identifier),统一资源 ...