目录

turtle:基本用法

一:画圆

二:奥运五环

三:美队盾牌

 四:繁星

 五:星空

 六:魔法阵

七:樱花树

 八:小猪佩奇

九:多来爱梦


 

turtle:基本用法

turtle.down() #移动时绘制图形,缺省时也为绘制

turtle.up() #移动时不绘制图形

turtle.pensize(width) #绘制图形时的宽度

turtle.color(colorstring) #绘制图形时的颜色

turtle.fillcolor(colorstring) #绘制图形的填充颜色

turtle.done() 停留在结束界面

turtle.hideturtle() 隐藏图标

turtle.showturtle() 显示图标

turtle.begin_fill() 开始填充

turtle.fillcolor(颜色) 填充颜色

turtle.end_fill() 结束填充

turtle.setheading() 改变笔头朝向

turtle.pencolor(colorstr)笔画颜色

turtle.pendown()(别名:turtle.pd(),turtle.down()):移动时绘制图形,缺省时也为绘制

 

运动命令:

turtle.forward(degree) #向前移动距离degree代表距离

turtle.backward(degree) #向后移动距离degree代表距离

turtle.right(degree) #向右移动多少度

turtle.left(degree) #向左移动多少度

turtle.goto(x,y) #将画笔移动到坐标为x,y的位置

turtle.stamp() #复制当前图形

turtle.speed(speed) #画笔绘制的速度范围[0,10]整数

turtle.clear() 清空turtle画的笔迹

turtle.reset() 清空窗口,重置turtle状态为起始状态

turtle.undo() (未测试)撤销上一个turtle动作

turtle.isvisible() (未测试)返回当前turtle是否可见

turtle.stamp() (未测试)复制当前图形

turtle.write(‘vshmily’) 写字符串’vshmily’

turtle.write(s[,font=(“font-name”,font_size,“font_type”)]) (未测试)写文本,s为文本内容,font是字体的参数,里面分别为字体名称,大小和类型;font为可选项, font的参数也是可选项 turtle.circle(7) 画一个半径为7的圆 turtle.circle(77, steps=3) 三边形,画一个半径为77的园的内切多边形

turtle.circle(77, 300) 圆弧为300度

turtle.screensize(800, 600, “green”)

turtle.screensize() #返回默认大小(400, 300)

 

一:画圆

import turtle  # 导入模块

turtle.screensize(800, 600, 'green') # 创建画布
turtle.circle(40) # 画笔循环画个圆,以画布中心为起点,半径为40

turtle.screensize() #返回默认大小(400, 300)

python用turtle画数字0 python用turtle画9_动画

 

import turtle as tur
tur.speed(0)  # 设置速度,让画的速度最快
# 第一个图
for i in range(12):
    tur.pencolor('black')
    tur.right(91)
    tur.circle(100)
# 第二个图
# for i in range(50):
#     tur.pencolor('red')
#     tur.right(63)
#     tur.circle(57)

tur.done()

python用turtle画数字0 python用turtle画9_动画_02

 

python用turtle画数字0 python用turtle画9_动画_03

二:奥运五环

import turtle as tur
tur.speed(0)
tur.pensize(9)
tur.color('black')
tur.circle(80)
tur.penup()
tur.goto(-140,0)
tur.pendown()

tur.color('blue')
tur.circle(80)
tur.penup()
tur.goto(140,0)
tur.pendown()

tur.color('red')
tur.circle(80)
tur.penup()
tur.goto(80,-100)
tur.pendown()

tur.color('yellow')
tur.circle(80)
tur.penup()
tur.goto(-60,-100)
tur.pendown()

tur.color('green')
tur.circle(80)
tur.penup()
tur.goto(-60,160)
tur.pendown()

tur.done()

三:美队盾牌

import turtle as tur
tur.speed(0)
tur.penup()
tur.goto(0,-100)
tur.pendown()
tur.color('red')
tur.begin_fill()
tur.circle(150)
tur.end_fill()

tur.penup()
tur.goto(0,-70)
tur.pendown()
tur.color('white')
tur.begin_fill()
tur.circle(120)
tur.end_fill()


tur.penup()
tur.goto(0,-50)
tur.pendown()
tur.color('red')
tur.begin_fill()
tur.circle(100)
tur.end_fill()

tur.penup()
tur.goto(0,-10)
tur.pendown()
tur.color('blue')
tur.begin_fill()
tur.circle(60)
tur.end_fill()

tur.penup()
tur.goto(-55,70)
tur.pendown()
tur.color('yellow')
tur.begin_fill()
for i in range(5):
    tur.forward(109)
    tur.right(144)
tur.end_fill()

tur.done()

python用turtle画数字0 python用turtle画9_ide_04

 四:繁星

import random
import turtle as tur

tur.speed(0)
tur.colormode(255)
tur.bgcolor('black')
tur.pensize(120)
tur.goto(-300,250)
tur.forward(600)

tur.color(50,50,50)
tur.penup()
tur.goto(-350,130)
tur.pendown()
tur.forward(700)

tur.color(75,75,75)
tur.penup()
tur.goto(-350,10)
tur.pendown()
tur.forward(700)

tur.color(100,100,100)
tur.penup()
tur.goto(-350,-110)
tur.pendown()
tur.forward(700)

tur.color(125,125,125)
tur.penup()
tur.goto(-350,-230)
tur.pendown()
tur.forward(800)

# 画星星
for i in range(10):
    tur.pensize(5)
    tur.color('yellow')
    tur.penup()
    tur.goto(random.randint(-200,200),random.randint(-200,200))
    tur.pendown()
    tur.begin_fill()
    for i in range(10):
        tur.forward(10)
        if i%2 == 0:
            tur.left(35)
        else:
            tur.right(105)

    tur.end_fill()

tur.done()

python用turtle画数字0 python用turtle画9_动画_05

 五:星空

from turtle import *
from random import random,randint
screen = Screen()
width ,height = 800,600
screen.setup(width,height)
screen.bgcolor("black")
screen.mode("logo")
screen.delay(0)#这里要设为0,否则很卡
t = Turtle(visible = False,shape='circle')
t.pencolor("white")
t.fillcolor("white")
t.penup()
t.setheading(-90)
t.goto(width/2,randint(int(-height/2),int(height/2)))
stars = []
for i in range(200):
    star = t.clone()
    s =random() /3
    star.shapesize(s,s)
    star.speed(int(s*10))
    star.setx(width/2 + randint(1,width))
    star.sety( randint(int(-height/2),int(height/2)))
    star.showturtle()
    stars.append(star)
while True:
    for star in stars:
        star.setx(star.xcor() - 3 * star.speed())
        if star.xcor()<-width/2:
            star.hideturtle()
            star.setx(width/2 + randint(1,width))
            star.sety( randint(int(-height/2),int(height/2)))
            star.showturtle()

python用turtle画数字0 python用turtle画9_python用turtle画数字0_06

 六:魔法阵

import turtle as t

def tcyuan(x, y, r):
    t.fillcolor("black")
    t.begin_fill()
    t.seth(0)
    y = y - r
    t.penup()
    t.goto(x, y)
    t.pendown()
    t.circle(r)
    t.end_fill()


def yuan(x, y, r):
    t.seth(0)
    y = y - r
    t.penup()
    t.goto(x, y)
    t.pendown()
    t.circle(r)


def yueliang():
    R = 110 - 1

    r = R - 22 - 1

    # 月亮填充
    t.penup()
    t.goto(-350 + 2 * R, 0)
    t.seth(90)
    t.fillcolor("black")
    t.begin_fill()
    t.circle(R, 359)
    t.left(90)
    t.fd(2)
    t.left(90)
    t.circle(-r, 359)
    t.left(90)
    t.fd(2)
    t.pendown()
    t.end_fill()
    # 轮廓
    yuan(-350 + R, 0, R)
    yuan(-350 + 44 + r - 2, 0, r - 2)


def zhixian(R, r, count, jiaodu):
    t.seth(90 + jiaodu)
    #    t.goto(0, 0)
    for i in range(count):
        t.penup()
        t.goto(0, 0)
        t.fd(r)
        t.pendown()
        t.fd(R - r)
        t.left(360 / count)


def zfx(R, r):
    jiange = 10
    #    t.pensize(jiange)
    t.seth(90)
    big = pow((R ** 2) * 2, 0.5)
    small = big - 2 * jiange
    for i in range(13):
        # 大线
        t.penup()
        t.goto(0, 0)
        t.fd(R)
        t.pendown()
        t.right(135)
        t.fd(big)
        # 小线
        t.left(135)
        t.penup()
        t.goto(0, 0)
        t.fd(pow((small ** 2) / 2, 0.5))
        t.pendown()
        t.right(135)
        t.fd(small)
        # 粗线
        t.pensize(8)
        t.pencolor("black")
        t.left(135)
        t.penup()
        t.goto(0, 0)
        t.fd((R + pow((small ** 2) / 2, 0.5)) / 2)
        t.pendown()
        t.right(135)
        t.fd((big + small) / 2)
        t.pensize(2)
        t.pencolor("yellow")
        t.seth(90 + i * 30)
    else:
        # 大线
        t.penup()
        t.goto(0, 0)
        t.fd(R)
        t.right(135)
        t.fd(big / 2)
        t.pendown()
        t.fd(big / 2)
        # 小线
        t.left(135)
        t.penup()
        t.goto(0, 0)
        t.fd(pow((small ** 2) / 2, 0.5))
        t.right(135)
        t.fd(small / 2)
        t.pendown()
        t.fd(small / 2)
        # 粗线
        t.pensize(8)
        t.pencolor("black")
        t.left(135)
        t.penup()
        t.goto(0, 0)
        t.fd((R + pow((small ** 2) / 2, 0.5)) / 2)
        t.right(135)
        t.fd((big + small) / 2 / 2)
        t.pendown()
        t.fd((big + small) / 2 / 2)
        t.pensize(2)
        t.pencolor("yellow")
        t.seth(90 + i * 30)


def wjx(r, jiaodu):
    t.fillcolor("black")
    t.penup()
    t.goto(0, 0)
    t.seth(90 + jiaodu)
    t.fd(r)
    t.pendown()
    t.right(18)
    t.begin_fill()
    for i in range(5):
        t.right(144)
        t.forward(144)
        t.left(72)
        t.forward(144)
    t.end_fill()
    if jiaodu != 0:
        t.seth(90 + jiaodu)
        for i in range(1, 6):
            t.penup()
            t.goto(0, 0)
            t.left(72)
            t.pendown()
            t.fd(r)


def xingzuo():
    r = 250
    t.penup()
    t.goto(20, -35)
    t.seth(-45)
    t.fd(r)
    t.pendown()
    xz = ['♒', '♓', '♈', '♉', '♌', '♍', '♎', '♏']
    for i in range(4):
        t.write(xz[i], font=("", 20, ""))
        t.penup()
        t.right(90)
        t.circle(-300, 30)
        t.left(90)
        t.pendown()
    t.penup()
    t.goto(-r / 4 + 10, 5)
    t.seth(135)
    t.fd(r)
    for i in range(4, 8):
        t.write(xz[i], font=("", 20, ""))
        t.penup()
        t.right(90)
        t.circle(-300, 30)
        t.left(90)
        t.pendown()


def dxnb(s):
    t.penup()
    t.fd(-19)
    t.left(90)
    t.fd(2)
    t.pendown()
    t.write(s, font=["KaiTi", 30, "bold"])


def taiyang():
    def haicao(r, i):
        # 海藻
        t.fillcolor("black")

        t.penup()
        if i == 0:
            t.goto(256, r)
        elif i == 1:
            t.goto(256 - r, 0)
        else:
            t.goto(256, -r)
        t.pendown()
        t.begin_fill()
        t.seth(2 + i * 90)
        t.circle(r / 2, 105)
        t.left(10)
        t.circle(-r / 3, 90)
        t.circle(r / 3, 60)
        t.left(20)
        t.circle(r / 3, -80)
        t.left(50)
        t.circle(-r + 10, -40)
        t.right(30)
        t.circle(r / 2 + 10, -50)
        t.penup()
        if i == 0:
            t.goto(256, r)
        elif i == 1:
            t.goto(256 - r, 0)
        else:
            t.goto(256, -r)
        t.pendown()
        t.end_fill()

        t.seth(2 + i * 90)
        t.circle(r / 2, 105)
        t.left(10)
        t.circle(-r / 3, 90)
        t.begin_fill()
        t.circle(r / 3, 60)
        t.left(20)
        t.circle(r / 3, -80)
        t.left(50)
        t.circle(-r + 10, -40)
        t.right(30)
        t.circle(r / 2 + 10, -50)
        t.right(30)
        t.circle(r / 2 - 2, 110)
        t.circle(-r / 3, 70)
        t.left(7)
        t.circle(r / 3, 85)
        t.end_fill()

        t.penup()
        if i == 0:
            t.goto(256, r)
            t.pendown()
            t.seth(180 - (2 + i * 90))
            t.circle(-(r / 2), 105)
        elif i == 1:
            t.goto(256 - r, 0)
            t.pendown()
            t.seth(- (2 + i * 90))
            t.circle(-(r / 2), 105)
        else:
            t.goto(256, -r)
            t.pendown()
            t.seth(180 - (2 + i * 90))
            t.circle(-(r / 2), 105)
        t.begin_fill()
        t.left(-10)
        t.circle(-(-r / 3), 90)
        t.circle(-(r / 3), 60)
        t.left(-20)
        t.circle(-(r / 3), -80)
        t.left(-50)
        t.circle(-(-r + 10), -40)
        t.right(-30)
        t.circle(-(r / 2 + 10), -50)
        t.end_fill()

        t.penup()
        if i == 0:
            t.goto(256, r)
            t.pendown()
            t.seth(180 - (2 + i * 90))
            t.circle(-(r / 2), 105)
        elif i == 1:
            t.goto(256 - r, 0)
            t.pendown()
            t.seth(- (2 + i * 90))
            t.circle(-(r / 2), 105)
        else:
            t.goto(256, -r)
            t.pendown()
            t.seth(180 - (2 + i * 90))
            t.circle(-(r / 2), 105)
        t.pendown()

        t.left(-10)
        t.circle(-(-r / 3), 90)
        t.circle(-(r / 3), 60)
        t.left(-20)
        t.begin_fill()
        t.circle(-(r / 3), -80)
        t.left(-50)
        t.circle(-(-r + 10), -40)
        t.right(-30)
        t.circle(-(r / 2 + 10), -50)
        t.right(-30)
        t.circle(-(r / 2 - 2), 110)
        t.circle(-(-r / 3), 70)
        t.left(-7)
        t.circle(-(r / 3), 85)
        t.end_fill()

    def xhaicao(r, i):
        t.penup()
        t.goto(256 + r, 0)
        t.seth(-90)
        t.circle(-r, 20)
        t.pendown()
        t.begin_fill()
        t.seth(30)
        t.circle(-r / 3, 100)
        t.circle(r / 6, 140)
        t.circle(-r / 11, 100)
        t.left(80)
        t.circle(-r / 2, -30)
        t.circle(r / 4, -140)
        t.circle(-r / 3, -60)
        t.end_fill()
        t.penup()
        t.goto(256 + r, 0)
        t.seth(-90)
        t.circle(-r, 30)
        t.pendown()
        t.seth(45)
        t.circle(-r / 4, 100)
        t.right(20)
        t.circle(r / 4, 140)
        t.right(10)
        t.circle(-r / 11, 90)

        t.penup()
        t.goto(256 + r, 0)
        t.seth(90)
        t.circle(r, 20)
        t.pendown()
        t.begin_fill()
        t.seth(-30)
        t.circle(-(-r / 3), 100)
        t.circle(-(r / 6), 140)
        t.circle(-(-r / 11), 100)
        t.left(-80)
        t.circle(-(-r / 2), -30)
        t.circle(-(r / 4), -140)
        t.circle(-(-r / 3), -60)
        t.end_fill()
        t.penup()
        t.goto(256 + r, 0)
        t.seth(90)
        t.circle(r, 30)
        t.pendown()
        t.seth(-45)
        t.circle(-(-r / 4), 100)
        t.right(-25)
        t.circle(-(r / 4), 140)
        t.right(-10)
        t.circle(-(-r / 11), 90)

    r = 50
    # 海藻
    haicao(r, 0)
    haicao(r, 1)
    haicao(r, 2)
    xhaicao(r, 3)

    # 大三角形
    t.fillcolor("black")

    for i in range(1, 4):
        temp = 3
        t.penup()
        t.goto(256, 0)
        t.seth(i * 90)
        t.pendown()
        t.begin_fill()
        t.right(22.5)
        t.fd(r)
        if i == 1:
            t.goto(256, 3 * r - temp)
            t.goto(256, 0)
            t.seth(i * 90 + 22.5)
            t.fd(r)
            t.goto(256, 3 * r - temp)
        elif i == 2:
            t.goto(256 - 3 * r + temp, 0)
            t.goto(256, 0)
            t.seth(i * 90 + 22.5)
            t.fd(r)
            t.goto(256 - 3 * r + temp, 0)
        else:
            t.goto(256, -3 * r + temp)
            t.goto(256, 0)
            t.seth(i * 90 + 22.5)
            t.fd(r)
            t.goto(256, -3 * r + temp)
        t.end_fill()
    # 小三角形
    x = pow(((2 * r) ** 2) / 2, 0.5) - 8
    for i in range(1, 5):
        t.penup()
        t.goto(256, 0)
        t.seth(i * 90)
        t.pendown()
        t.begin_fill()
        t.right(22.5)
        t.fd(r)
        if i == 1:
            t.goto(256 + x, x)
            t.goto(256, 0)
            t.right(45)
            t.fd(r)
            t.goto(256 + x, x)
        elif i == 2:
            t.goto(256 - x, x)
            t.goto(256, 0)
            t.right(45)
            t.fd(r)
            t.goto(256 - x, x)
        elif i == 3:
            t.goto(256 - x, -x)
            t.goto(256, 0)
            t.right(45)
            t.fd(r)
            t.goto(256 - x, -x)
        else:
            t.goto(256 + x, -x)
            t.goto(256, 0)
            t.right(45)
            t.fd(r)
            t.goto(256 + x, -x)
        t.end_fill()

    # 圆
    #    t.begin_fill()
    tcyuan(256, 0, r)


# 初始化
t.setup(1500, 800, 0, 0)
t.speed(0)
t.bgcolor("black")
t.pencolor("yellow")
t.pensize(2)
# 最大的圆
yuan(0, 0, 350)
yuan(0, 0, 325)
yuan(0, 0, 321)
yuan(0, 0, 306)
zhixian(321, 306, 72, 0)
# 小圆
yuan(0, 0, 204)
yuan(0, 0, 200)
yuan(0, 0, 186)
zhixian(200, 186, 72, 0)
# 正方形边框以及直线
zhixian(290, 213, 12, 0)
zhixian(248, 205, 12, 15)
zfx(306, 204)
# 里五角星
wjx(200, 36)
# 月亮
yueliang()
# 太阳
taiyang()
# 最小圆
tcyuan(0, 328, 22)
dxnb("北")
tcyuan(0, -328, 22)
dxnb("南")
tcyuan(-328, 0, 22)
dxnb("西")
tcyuan(328, 0, 22)
dxnb("東")

# 外五角星
wjx(200, 0)
# 星座
xingzuo()
t.penup()
t.goto(-500, -500)
t.pendown()
t.done()

python用turtle画数字0 python用turtle画9_ide_07

七:樱花树

import turtle as tur
import random
import math
def tree(n, l):
    tur.setup(800, 600)
    tur.pd()  # 下笔
    # 阴影效果
    t = math.cos(math.radians(tur.heading() + 45)) / 8 + 0.25
    tur.pencolor('tan')
    tur.pensize(n / 3)
    tur.forward(l)  # 画树枝
    if n > 0:
        b = random.random() * 15 + 10  # 右分支偏转角度
        c = random.random() * 15 + 10  # 左分支偏转角度
        d = l * (random.random() * 0.25 + 0.7)  # 下一个分支的长度
        # 右转一定角度,画右分支
        tur.right(b)
        tree(n - 1, d)
        # 左转一定角度,画左分支
        tur.left(b + c)
        tree(n - 1, d)
        # 转回来
        tur.right(c)
    else:
        # 画叶子
        tur.right(90)
        n = math.cos(math.radians(tur.heading() - 45)) / 4 + 0.5
        tur.pencolor('lightcoral')
        tur.circle(3)
        tur.left(90)
        # 添加0.3倍的飘落叶子
        if (random.random() > 0.7):
            tur.pu()
            # 飘落
            t = tur.heading()
            an = -40 + random.random() * 40
            tur.setheading(an)
            dis = int(800 * random.random() * 0.5 + 400 * random.random() * 0.3 + 200 * random.random() * 0.2)
            tur.forward(dis)
            tur.setheading(t)
            # 画叶子
            tur.pd()
            tur.right(90)
            n = math.cos(math.radians(tur.heading() - 45)) / 4 + 0.5
            tur.pencolor(n * 0.5 + 0.5, 0.4 + n * 0.4, 0.4 + n * 0.4)
            tur.circle(2)
            tur.left(90)
            tur.pu()
            # 返回
            t = tur.heading()
            tur.setheading(an)
            tur.backward(dis)
            tur.setheading(t)

    tur.pu()
    tur.backward(l)  # 退回

tur.bgcolor('white')  # 背景色
tur.ht()  # 隐藏turtle
tur.speed(0)  # 速度,1-10渐进,0最快
tur.tracer(0, 0)
tur.pu()  # 抬笔
tur.backward(100)
tur.left(90)  # 左转90度
tur.pu()  # 抬笔
tur.backward(300)  # 后退300
tree(10, 100)  # 递归7层
tur.done()

python用turtle画数字0 python用turtle画9_动画_08

 八:小猪佩奇

# -*- coding:utf-8 -*-

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()

九:多来爱梦

import turtle as t
# t.speed(5)
t.pensize(8)
t.hideturtle()
t.screensize(500, 500, bg='white')
# 猫脸
# 先画个圆
t.fillcolor('#00A1E8')
t.begin_fill()
t.circle(120)
t.end_fill()
# 再画个小圆
t.pensize(3)
t.fillcolor('white')
t.begin_fill()
t.circle(100)
t.end_fill()
# 鼻子
t.pu()  # 表示将画笔抬起,也就是相当于海龟在飞行的意思。
t.home()  # 返回初始位置:home()
t.goto(0, 134)  # 将画笔移动到坐标为x,y的位置
t.pd()  # 表示将画笔落下,让海龟爬行
t.pensize(4)  # 画笔宽度,海龟的腰围
t.fillcolor("#EA0014")
t.begin_fill()
t.circle(18)
t.end_fill()
#
t.pu()
t.goto(7, 155)
t.pensize(2)
t.color('white', 'white')
t.pd()
t.begin_fill()
t.circle(4)
t.end_fill()
# 画眼圈
t.pu()
t.goto(-30, 160)
t.pensize(4)
t.pd()
t.color('black', 'white')
t.begin_fill()
a = 0.4
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a = a + 0.08
        t.lt(3)  # 向左转3度
        t.fd(a)  # 向前走a的步长
    else:
        a = a - 0.08
        t.lt(3)
        t.fd(a)
t.end_fill()
t.pu()
t.goto(30, 160)
t.pensize(4)
t.pd()
t.color('black', 'white')
t.begin_fill()
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a = a + 0.08
        t.lt(3)  # 向左转3度
        t.fd(a)  # 向前走a的步长
    else:
        a = a - 0.08
        t.lt(3)
        t.fd(a)
t.end_fill()
# 眼睛
t.pu()
t.goto(-38, 190)
t.pensize(8)
t.pd()
t.right(-30)
t.forward(15)
t.right(70)
t.forward(15)
t.pu()
t.goto(15, 185)
t.pensize(4)
t.pd()
t.color('black', 'black')
t.begin_fill()
t.circle(13)
t.end_fill()
t.pu()
t.goto(13, 190)
t.pensize(2)
t.pd()
t.color('white', 'white')
t.begin_fill()
t.circle(5)
t.end_fill()
# 胡子
t.pu()
t.home()
t.goto(0, 134)
t.pensize(4)
t.pencolor('black')
t.pd()
t.right(90)
t.forward(40)
t.pu()
t.home()
t.goto(0, 124)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(10)
t.forward(80)
t.pu()
t.home()
t.goto(0, 114)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(6)
t.forward(80)
t.pu()
t.home()
t.goto(0, 104)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(0)
t.forward(80)
# 左边的胡子
t.pu()
t.home()
t.goto(0, 124)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(170)
t.forward(80)
t.pu()
t.home()
t.goto(0, 114)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(174)
t.forward(80)
t.pu()
t.home()
t.goto(0, 104)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(180)
t.forward(80)
# 笑脸
t.pu()
t.goto(-70, 70)
t.pd()
t.color('black', 'red')
t.pensize(6)
t.seth(-60)
t.begin_fill()
t.circle(80, 40)
t.circle(80, 80)
t.end_fill()
t.pu()
t.home()
t.goto(-80, 70)
t.pd()
t.forward(160)
t.pu()
t.home()
t.goto(-50, 50)
t.pd()
t.pensize(1)
t.fillcolor("#eb6e1a")
t.seth(40)
t.begin_fill()
t.circle(-40, 40)
t.circle(-40, 40)
t.seth(40)
t.circle(-40, 40)
t.circle(-40, 40)
t.seth(220)
t.circle(-80, 40)
t.circle(-80, 40)
t.end_fill()
# 领带
t.pu()
t.goto(-70, 12)
t.pensize(14)
t.pencolor('red')
t.pd()
t.seth(-20)
t.circle(200, 30)
t.circle(200, 10)
# 铃铛
t.pu()
t.goto(0, -46)
t.pd()
t.pensize(3)
t.color("black", '#f8d102')
t.begin_fill()
t.circle(25)
t.end_fill()
t.pu()
t.goto(-5, -40)
t.pd()
t.pensize(2)
t.color("black", '#79675d')
t.begin_fill()
t.circle(5)
t.end_fill()
t.pensize(3)
t.right(115)
t.forward(7)
t.mainloop()