利用python编写小游戏,用python编写的游戏

大家好,小编来为大家解答以下问题,利用python编写小游戏,用python编写的游戏,现在让我们一起来看看吧!

大家好,给大家分享一下python创意小作品100行代码左右,很多人还不知道这一点。下面详细解释一下。现在让我们来看看!

Source code download: 本文相关源码

白天停电停网了一天后,又遇到一些事情心情难过,白天看到一些有趣的图像,是用python的turtle库画图。

晚上来电了后,也不想学习了,就看网上一些教程学习画图python编程好学吗。

1. 飞机

import turtle
#太阳
turtle.color('red')
turtle.penup()
(250,200)
turtle.pendown()
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
turtle.color('black','blue')
turtle.begin_fill()
#飞机
turtle.penup()
()
turtle.pendown()
turtle.pensize(5)
(-300,150)
(100,50)
(0,0)
turtle.end_fill()
(-30,-125)
(-50,-50)
turtle.begin_fill()
(-300,150)
(-125,-125)
(-50,-50)
(-30,-125)
(-85,-85)
turtle.end_fill()
#线条
turtle.pensize(3)
turtle.penup()
(75,25)
turtle.pendown()
(200,0)
turtle.penup()
(50,-5)
turtle.pendown()
(250,-30)
turtle.penup()
(10,-80)
turtle.pendown()
(100,-150)
turtle.penup()
(-80,-125)
turtle.pendown()
(120,-200)
()
turtle.exitonclick()

2. 玫瑰花

import turtle as T
import time

T.setup(1000,800,0,0)
T.speed(0)
T.penup()
T.seth(90)
T.fd(340)
T.seth(0)
T.pendown()

T.speed(5)
T.begin_fill()
T.fillcolor('red')
T.circle(50,30)

for i in range(10):
    T.fd(1)
    T.left(10)

T.circle(40,40)

for i in range(6):
    T.fd(1)
    T.left(3)

T.circle(80,40)

for i in range(20):
    T.fd(0.5)
    T.left(5)

T.circle(80,45)

for i in range(10):
    T.fd(2)
    T.left(1)

T.circle(80,25)

for i in range(20):
    T.fd(1)
    T.left(4)

T.circle(50,50)

time.sleep(0.1)

T.circle(120,55)

T.speed(0)

T.seth(-90)
T.fd(70)

T.right(150)
T.fd(20)

T.left(140)
T.circle(140,90)

T.left(30)
T.circle(160,100)

T.left(130)
T.fd(25)

T.penup()
T.right(150)
T.circle(40,80)
T.pendown()

T.left(115)
T.fd(60)

T.penup()
T.left(180)
T.fd(60)
T.pendown()

T.end_fill()

T.right(120)
T.circle(-50,50)
T.circle(-20,90)

T.speed(1)
T.fd(75)

T.speed(0)
T.circle(90,110)

T.penup()
T.left(162)
T.fd(185)
T.left(170)
T.pendown()
T.circle(200,10)
T.circle(100,40)
T.circle(-52,115)
T.left(20)
T.circle(100,20)
T.circle(300,20)
T.speed(1)
T.fd(250)

T.penup()
T.speed(0)
T.left(180)
T.fd(250)
T.circle(-300,7)
T.right(80)
T.circle(200,5)
T.pendown()

T.left(60)
T.begin_fill()
T.fillcolor('green')
T.circle(-80,100)
T.right(90)
T.fd(10)
T.left(20)
T.circle(-63,127)
T.end_fill()

T.penup()
T.left(50)
T.fd(20)
T.left(180)

T.pendown()
T.circle(200,25)

T.penup()
T.right(150)

T.fd(180)

T.right(40)
T.pendown()
T.begin_fill()
T.fillcolor('green')
T.circle(-100,80)
T.right(150)
T.fd(10)
T.left(60)
T.circle(-80,98)
T.end_fill()

T.penup()
T.left(60)
T.fd(13)
T.left(180)

T.pendown()
T.speed(1)
T.circle(-200,23)

T.exitonclick()

3. 灰色的樱花树

import turtle as T
from random import *
from math import *
def tree(n, l):
    T.pd()
    t = cos(radians(T.heading() + 45)) / 8 + 0.25
    T.pencolor(t, t, t)
    T.pensize(n / 4)
    T.forward(l)
    if n > 0:
        b = random() * 15 + 10
        c = random() * 15 + 10
        d = l * (random() * 0.35 + 0.6)
        T.right(b)
        tree(n - 1, d)
        T.left(b + c)
        tree(n - 1, d)
        T.right(c)
    else:
        T.right(90)
        n = cos(radians(T.heading() - 45)) / 4 + 0.5
        T.pencolor(n, n, n)
        T.circle(2)
        T.left(90)
    T.pu()
    T.backward(l)
T.bgcolor(0.5, 0.5, 0.5)
T.ht()
T.speed(0)
T.tracer(0, 0)
T.left(90)
T.pu()
T.backward(300)
tree(13, 100)
T.done()

4. 落英缤纷

import turtle as T

from turtle import *
from random import *
from math import *

def tree(n,l):
    T.pd()#下笔
    #阴影效果
    t = cos(radians(T.heading()+45))/8+0.25
    T.pencolor(t,t,t)
    T.pensize(n/3)
    T.forward(l)#画树枝

    if n>0:
        b = random()*15+10 #右分支偏转角度
        c = random()*15+10 #左分支偏转角度
        d = l*(random()*0.25+0.7) #下一个分支的长度
        #右转一定角度,画右分支
        T.right(b)
        tree(n-1,d)
        #左转一定角度,画左分支
        T.left(b+c)
        tree(n-1,d)
        #转回来
        T.right(c)
    else:
        #画叶子
        T.right(90)
        n=cos(radians(T.heading()-45))/4+0.5
        T.pencolor(n,n*0.8,n*0.8)
        T.circle(3)
        T.left(90)
        #添加0.3倍的飘落叶子
        if(random()>0.7):
            T.pu()
            #飘落
            t = T.heading()
            an = -40 +random()*40
            T.setheading(an)
            dis = int(800*random()*0.5 + 400*random()*0.3 + 200*random()*0.2)
            T.forward(dis)
            T.setheading(t)
            #画叶子
            T.pd()
            T.right(90)
            n = cos(radians(T.heading()-45))/4+0.5
            T.pencolor(n*0.5+0.5,0.4+n*0.4,0.4+n*0.4)
            T.circle(2)
            T.left(90)
            T.pu()
            #返回
            t=T.heading()
            T.setheading(an)
            T.backward(dis)
            T.setheading(t)
    T.pu()
    T.backward(l)#退回

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

3. 动态樱花树

import random
import time
import turtle as T
# 画樱花的躯干(60,t)
def Tree(branch, t):
    time.sleep(0.0005)
    if branch > 3:
        if 8 <= branch <= 12:
            if random.randint(0, 2) == 0:
                t.color('snow')  # 白
            else:
                t.color('lightcoral')  # 淡珊瑚色
            t.pensize(branch / 3)
        elif branch < 8:
            if random.randint(0, 1) == 0:
                t.color('snow')
            else:
                t.color('lightcoral')  # 淡珊瑚色
            t.pensize(branch / 2)
        else:
            t.color('sienna')  # 赭(zhě)色
            t.pensize(branch / 10)  # 6
        t.forward(branch)
        a = 1.5 * random.random()
        t.right(20 * a)
        b = 1.5 * random.random()
        Tree(branch - 10 * b, t)
        t.left(40 * a)
        Tree(branch - 10 * b, t)
        t.right(20 * a)
        t.up()
        t.backward(branch)
        t.down()
# 掉落的花瓣
def Petal(m, t):
    for i in range(m):
        a = 200 - 400 * random.random()
        b = 10 - 20 * random.random()
        t.up()
        t.forward(b)
        t.left(90)
        t.forward(a)
        t.down()
        t.color('lightcoral')  # 淡珊瑚色
        t.circle(1)
        t.up()
        t.backward(a)
        t.right(90)
        t.backward(b)
# 绘图区域
t = T.Turtle()
# 画布大小
w = T.Screen()
t.hideturtle()  # 隐藏画笔
t.getscreen().tracer(5, 0)
w.screensize(bg='wheat')  # wheat小麦
t.left(90)
t.up()
t.backward(150)
t.down()
t.color('sienna')
# 画樱花的躯干
Tree(60, t)
# 掉落的花瓣
Petal(200, t)
w.exitonclick()

4. 蓝胖子

# * -- utf-8 -- *
# Author: Tang

import turtle as t

t.speed(10)
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()
t.goto(0, 134)
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()

5. 小猪佩奇

#!/usr/bin/env python2
# coding=utf-8

import turtle as t

t.pensize(4)
t.hideturtle()
t.colormode(255)
t.color((255, 155, 192), "pink")
t.setup(840, 500)
t.speed(10)

# 鼻子
t.pu()
t.goto(-100, 100)
t.pd()
t.seth(-30)
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.seth(90)
t.fd(25)
t.seth(0)
t.fd(10)
t.pd()
t.pencolor(255, 155, 192)
t.seth(10)
t.begin_fill()
t.circle(5)
t.color(160, 82, 45)
t.end_fill()

t.pu()
t.seth(0)
t.fd(20)
t.pd()
t.pencolor(255, 155, 192)
t.seth(10)
t.begin_fill()
t.circle(5)
t.color(160, 82, 45)
t.end_fill()

# 头
t.color((255, 155, 192), "pink")
t.pu()
t.seth(90)
t.fd(41)
t.seth(0)
t.fd(0)
t.pd()
t.begin_fill()
t.seth(180)
t.circle(300, -30)
t.circle(100, -60)
t.circle(80, -100)
t.circle(150, -20)
t.circle(60, -95)
t.seth(161)
t.circle(-300, 15)
t.pu()
t.goto(-100, 100)
t.pd()
t.seth(-30)
a = 0.4
for i in range(60):
    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.color((255, 155, 192), "pink")
t.pu()
t.seth(90)
t.fd(-7)
t.seth(0)
t.fd(70)
t.pd()
t.begin_fill()
t.seth(100)
t.circle(-50, 50)
t.circle(-10, 120)
t.circle(-50, 54)
t.end_fill()

t.pu()
t.seth(90)
t.fd(-12)
t.seth(0)
t.fd(30)
t.pd()
t.begin_fill()
t.seth(100)
t.circle(-50, 50)
t.circle(-10, 120)
t.circle(-50, 56)
t.end_fill()

# 眼睛
t.color((255, 155, 192), "white")
t.pu()
t.seth(90)
t.fd(-20)
t.seth(0)
t.fd(-95)
t.pd()
t.begin_fill()
t.circle(15)
t.end_fill()

t.color("black")
t.pu()
t.seth(90)
t.fd(12)
t.seth(0)
t.fd(-3)
t.pd()
t.begin_fill()
t.circle(3)
t.end_fill()

t.color((255, 155, 192), "white")
t.pu()
t.seth(90)
t.fd(-25)
t.seth(0)
t.fd(40)
t.pd()
t.begin_fill()
t.circle(15)
t.end_fill()

t.color("black")
t.pu()
t.seth(90)
t.fd(12)
t.seth(0)
t.fd(-3)
t.pd()
t.begin_fill()
t.circle(3)
t.end_fill()

# 腮
t.color((255, 155, 192))
t.pu()
t.seth(90)
t.fd(-95)
t.seth(0)
t.fd(65)
t.pd()
t.begin_fill()
t.circle(30)
t.end_fill()

# 嘴
t.color(239, 69, 19)
t.pu()
t.seth(90)
t.fd(15)
t.seth(0)
t.fd(-100)
t.pd()
t.seth(-80)
t.circle(30, 40)
t.circle(40, 80)

# 身体
t.color("red", (255, 99, 71))
t.pu()
t.seth(90)
t.fd(-20)
t.seth(0)
t.fd(-78)
t.pd()
t.begin_fill()
t.seth(-130)
t.circle(100, 10)
t.circle(300, 30)
t.seth(0)
t.fd(230)
t.seth(90)
t.circle(300, 30)
t.circle(100, 3)
t.color((255, 155, 192), (255, 100, 100))
t.seth(-135)
t.circle(-80, 63)
t.circle(-150, 24)
t.end_fill()

# 手
t.color((255, 155, 192))
t.pu()
t.seth(90)
t.fd(-40)
t.seth(0)
t.fd(-27)
t.pd()
t.seth(-160)
t.circle(300, 15)
t.pu()
t.seth(90)
t.fd(15)
t.seth(0)
t.fd(0)
t.pd()
t.seth(-10)
t.circle(-20, 90)

t.pu()
t.seth(90)
t.fd(30)
t.seth(0)
t.fd(237)
t.pd()
t.seth(-20)
t.circle(-300, 15)
t.pu()
t.seth(90)
t.fd(20)
t.seth(0)
t.fd(0)
t.pd()
t.seth(-170)
t.circle(20, 90)

# 脚
t.pensize(10)
t.color((240, 128, 128))
t.pu()
t.seth(90)
t.fd(-75)
t.seth(0)
t.fd(-180)
t.pd()
t.seth(-90)
t.fd(40)
t.seth(-180)
t.color("black")
t.pensize(15)
t.fd(20)

t.pensize(10)
t.color((240, 128, 128))
t.pu()
t.seth(90)
t.fd(40)
t.seth(0)
t.fd(90)
t.pd()
t.seth(-90)
t.fd(40)
t.seth(-180)
t.color("black")
t.pensize(15)
t.fd(20)

# 尾巴
t.pensize(4)
t.color((255, 155, 192))
t.pu()
t.seth(90)
t.fd(70)
t.seth(0)
t.fd(95)
t.pd()
t.seth(0)
t.circle(70, 20)
t.circle(10, 330)
t.circle(70, 30)

6. Iphone 4

import turtle
##圆角矩形,参数:length(宽),high(高),cor_angle(弧度值)cor_rad(圆形轨迹半径的位置)
def round_rectangle(length, high, cor_angle, cor_rad):
    for i in range(2):
        (high)
        turtle.circle(cor_rad, cor_angle)
        (length)
        turtle.circle(cor_rad, cor_angle)


def main2():
    turtle.setup(1300, 800, 0, 0)  # 启动窗口的大小,左上角右上角坐标
    pythonsize = 2
    turtle.pensize(pythonsize)  # 运行宽度
    turtle.speed(10)
    (90)  # 启动时运行的方向(角度)

    # 最外边框
    turtle.pencolor("#8E8e8e")
    turtle.penup()
    (202, -202)
    turtle.pendown()
    round_rectangle(244, 484, 90, 30)
    # 填充
    turtle.penup()
    (200, -200)
    turtle.pendown()
    turtle.begin_fill()
    turtle.color("#F0F0F0")
    round_rectangle(240, 480, 90, 30)
    turtle.end_fill()

    # 手机屏
    turtle.pencolor("black")  # (#3000440)
    turtle.penup()
    (185, -150)
    turtle.pendown()
    turtle.begin_fill()
    turtle.color("black")
    round_rectangle(270, 380, 90, 0)
    turtle.end_fill()

    # 听筒
    turtle.penup()
    (80, 265)
    turtle.pendown()
    turtle.begin_fill()
    turtle.color("#9d9d9d")
    round_rectangle(60, 4, 90, 1)
    turtle.end_fill()

    # 听筒上面的小黑
    turtle.penup()
    (67, 290)
    turtle.pendown()
    turtle.begin_fill()
    turtle.color("#3c3c3c")
    round_rectangle(36, 4, 90, 1)
    turtle.end_fill()

    # 摄像头
    turtle.penup()
    (0, 265)
    turtle.pendown()
    turtle.begin_fill()
    turtle.color("#3c3c3c")
    turtle.circle(6, 360)
    turtle.end_fill()

    # home健
    turtle.pencolor("#9d9d9d")  # (#3000440)
    turtle.penup()
    (75, -185)
    turtle.pendown()
    turtle.circle(25, 360)

    # home健图案
    turtle.pencolor("#9d9d9d")  # (#3000440)
    turtle.penup()
    (60, -190)
    turtle.pendown()
    (10, 10, 90, 5)


main2()

7. 小黄人

import turtle as t
# t = turtle.Turtle()
wn = t.Screen()
t.colormode(255)
t.hideturtle()
t.speed(0)
t.penup()
t.pensize(4)
t.goto(100,0)
t.pendown()
t.left(90)
t.color((0,0,0),(255,255,0))
#身体绘制上色
t.begin_fill()
t.forward(200)
t.circle(100,180)
t.forward(200)
t.circle(100,180)
t.end_fill()
#右眼睛绘制上色
t.pensize(12)
t.penup()
t.goto(-100,200)
t.pendown()
t.right(100)
t.circle(500,23)
t.pensize(3)
t.penup()
t.goto(0,200)
t.pendown()
t.seth(270)
t.color("black","white")
t.begin_fill()
t.circle(30)
t.end_fill()
t.penup()
t.goto(15,200)
t.pendown()
t.color("black","black")
t.begin_fill()
t.circle(15)
t.end_fill()
t.penup()
t.goto(35,205)
t.color("black","white")
t.begin_fill()
t.circle(5)
t.end_fill()
#左眼睛绘制上色
t.pensize(3)
t.penup()
t.goto(0,200)
t.pendown()
t.seth(90)
t.color("black","white")
t.begin_fill()
t.circle(30)
t.end_fill()
t.penup()
t.goto(-15,200)
t.pendown()
t.color("black","black")
t.begin_fill()
t.circle(15)
t.end_fill()
t.penup()
t.goto(-35,205)
t.color("black","white")
t.begin_fill()
t.circle(5)
t.end_fill()
#嘴绘制上色
t.penup()
t.goto(-20,100)
t.pendown()
t.seth(270)
t.color("black","white")
t.begin_fill()
t.circle(20,180)
t.left(90)
t.forward(40)
t.end_fill()
#裤子绘制上色
t.penup()
t.goto(-100,0)
t.pendown()
t.seth(0)
t.color("black","blue")
t.begin_fill()
t.forward(20)
t.left(90)
t.forward(40)
t.right(90)
t.forward(160)
t.right(90)
t.forward(40)
t.left(90)
t.forward(20)
t.seth(270)
t.penup()
t.goto(-100,0)
t.circle(100,180)
t.end_fill()
#左裤子腰带
t.penup()
t.goto(-70,20)
t.pendown()
t.color("black","blue")
t.begin_fill()
t.seth(45)
t.forward(15)
t.left(90)
t.forward(60)
t.seth(270)
t.forward(15)
t.left(40)
t.forward(50)
t.end_fill()
t.left(180)
t.goto(-70,30)
t.dot()
#右裤腰带
t.penup()
t.goto(70,20)
t.pendown()
t.color("black","blue")
t.begin_fill()
t.seth(135)
t.forward(15)
t.right(90)
t.forward(60)
t.seth(270)
t.forward(15)
t.right(40)
t.forward(50)
t.end_fill()
t.left(180)
t.goto(70,30)
t.dot()
#脚
t.penup()
t.goto(4,-100)
t.pendown()
t.seth(270)
t.color("black","black")
t.begin_fill()
t.forward(30)
t.left(90)
t.forward(40)
t.seth(20)
t.circle(10,180)
t.circle(400,2)
t.seth(90)
t.forward(20)
t.goto(4,-100)
t.end_fill()
t.penup()
t.goto(-4,-100)
t.pendown()
t.seth(270)
t.color("black","black")
t.begin_fill()
t.forward(30)
t.right(90)
t.forward(40)
t.seth(20)
t.circle(10,-225)
t.circle(400,-3)
t.seth(90)
t.forward(21)
t.goto(-4,-100)
t.end_fill()
#左手
t.penup()
t.goto(-100,50)
t.pendown()
t.seth(225)
t.color("black","yellow")
t.begin_fill()
t.forward(40)
t.left(90)
t.forward(35)
t.seth(90)
t.forward(50)
t.end_fill()
#右手
t.penup()
t.goto(100,50)
t.pendown()
t.seth(315)
t.color("black","yellow")
t.begin_fill()
t.forward(40)
t.right(90)
t.forward(36)
t.seth(90)
t.forward(50)
t.end_fill()
#
t.penup()
t.goto(0,-100)
t.pendown()
t.forward(30)
#
t.penup()
t.goto(0,-20)
t.pendown()
t.color("yellow")
t.begin_fill()
t.seth(45)
t.forward(20)
t.circle(10,180)
t.right(90)
t.circle(10,180)
t.forward(20)
t.end_fill()
#
t.penup()
t.color("black")
t.goto(-100,-20)
t.pendown()
t.circle(30,90)
t.penup()
t.goto(100,-20)
t.pendown()
t.circle(30,-90)
#头顶
t.penup()
t.goto(2,300)
t.pendown()
t.begin_fill()
t.seth(135)
t.circle(100,40)
t.end_fill()
t.penup()
t.goto(2,300)
t.pendown()
t.begin_fill()
t.seth(45)
t.circle(100,40)
t.exitonclick()

8. 皮卡丘

# coding:utf-8
import turtle as t
import time
# 皮卡丘
# 基础设置
t.screensize(800, 600)
t.pensize(2)  # 设置画笔的大小
t.speed(10)  # 设置画笔速度为10
# 画左偏曲线函数
def radian_left(ang, dis, step, n):
    for i in range(n):
        dis += step  # dis增大step
        t.lt(ang)  # 向左转ang度
        t.fd(dis)  # 向前走dis的步长
def radian_right(ang, dis, step, n):
    for i in range(n):
        dis += step
        t.rt(ang)  # 向左转ang度
        t.fd(dis)  # 向前走dis的步长
# 画耳朵
def InitEars():
    t.color("black", "yellow")
    # 左耳朵曲线
    t.pu()  # 提笔
    t.goto(-50, 100)  # 笔头初始位置
    t.pd()  # 下笔
    t.setheading(110)  # 画笔角度
    t.begin_fill()
    radian_left(1.2, 0.4, 0.1, 40)
    t.setheading(270)  # 画笔角度
    radian_left(1.2, 0.4, 0.1, 40)
    t.setheading(44)  # 画笔角度
    t.forward(32)
    t.end_fill()
    # 右耳朵曲线
    t.pu()  # 提笔
    t.goto(50, 100)  # 笔头初始位置
    t.pd()  # 下笔
    t.setheading(70)  # 画笔角度
    t.begin_fill()
    radian_right(1.2, 0.4, 0.1, 40)
    t.setheading(270)  # 画笔角度
    radian_right(1.2, 0.4, 0.1, 40)
    t.setheading(136)  # 画笔角度
    t.forward(32)
    t.end_fill()
    # 耳朵黑
    t.begin_fill()
    t.fillcolor("black")
    t.pu()  # 提笔
    t.goto(88, 141)  # 笔头初始位置
    t.pd()  # 下笔
    t.setheading(35)  # 画笔角度
    radian_right(1.2, 1.6, 0.1, 16)
    t.setheading(270)  # 画笔角度
    radian_right(1.2, 0.4, 0.1, 25)
    t.setheading(132)  # 画笔角度
    t.forward(31)
    t.end_fill()
    t.begin_fill()
    t.fillcolor("black")
    t.pu()  # 提笔
    t.goto(-88, 141)  # 笔头初始位置
    t.pd()  # 下笔
    t.setheading(145)  # 画笔角度
    radian_left(1.2, 1.6, 0.1, 16)
    t.setheading(270)  # 画笔角度
    radian_left(1.2, 0.4, 0.1, 25)
    t.setheading(48)  # 画笔角度
    t.forward(31)
    t.end_fill()
# 画尾巴
def InitTail():
    # 尾巴
    t.begin_fill()
    t.fillcolor("yellow")
    t.pu()  # 提笔
    t.goto(64, -140)  # 笔头初始位置
    t.pd()  # 下笔
    t.setheading(10)  # 画笔角度
    t.forward(20)
    t.setheading(90)  # 画笔角度
    t.forward(20)
    t.setheading(10)  # 画笔角度
    t.forward(10)
    t.setheading(80)  # 画笔角度
    t.forward(100)
    t.setheading(35)  # 画笔角度
    t.forward(80)
    t.setheading(260)  # 画笔角度
    t.forward(100)
    t.setheading(205)  # 画笔角度
    t.forward(40)
    t.setheading(260)  # 画笔角度
    t.forward(37)
    t.setheading(205)  # 画笔角度
    t.forward(20)
    t.setheading(260)  # 画笔角度
    t.forward(25)
    t.setheading(175)  # 画笔角度
    t.forward(30)
    t.setheading(100)  # 画笔角度
    t.forward(13)
    t.end_fill()
# 画脚
def InitFoots():
    # 脚
    t.begin_fill()
    t.fillcolor("yellow")
    t.pensize(2)
    t.pu()  # 提笔
    t.goto(-70, -200)  # 笔头初始位置
    t.pd()  # 下笔
    t.setheading(225)  # 画笔角度
    radian_left(0.5, 1.2, 0, 12)
    radian_left(35, 0.6, 0, 4)
    radian_left(1, 1.2, 0, 18)
    t.setheading(160)  # 画笔角度
    t.forward(13)
    t.end_fill()
    t.begin_fill()
    t.fillcolor("yellow")
    t.pensize(2)
    t.pu()  # 提笔
    t.goto(70, -200)  # 笔头初始位置
    t.pd()  # 下笔
    t.setheading(315)  # 画笔角度
    radian_right(0.5, 1.2, 0, 12)
    radian_right(35, 0.6, 0, 4)
    radian_right(1, 1.2, 0, 18)
    t.setheading(20)  # 画笔角度
    t.forward(13)
    t.end_fill()
# 画身体
def InitBody():
    # 外形轮廓
    t.begin_fill()
    t.pu()  # 提笔
    t.goto(112, 0)  # 笔头初始位置
    t.pd()  # 下笔
    t.setheading(90)  # 画笔角度
    t.circle(112, 180)
    t.setheading(250)  # 画笔角度
    radian_left(1.6, 1.3, 0, 50)
    radian_left(0.8, 1.5, 0, 25)
    t.setheading(255)  # 画笔角度
    radian_left(0.4, 1.6, 0.2, 27)
    radian_left(2.8, 1, 0, 45)
    radian_right(0.9, 1.4, 0, 31)
    t.setheading(355)  # 画笔角度
    radian_right(0.9, 1.4, 0, 31)
    radian_left(2.8, 1, 0, 45)
    radian_left(0.4, 7.2, -0.2, 27)
    t.setheading(10)  # 画笔角度
    radian_left(0.8, 1.5, 0, 25)
    radian_left(1.6, 1.3, 0, 50)
    t.end_fill()
def InitEyes():
    # 左眼睛
    t.begin_fill()
    t.fillcolor("black")
    t.pu()  # 提笔
    t.goto(-46, 10)  # 笔头初始位置
    t.pd()  # 下笔
    t.setheading(90)  # 画笔角度
    t.circle(5, 360)
    t.end_fill()
    # 右眼睛
    t.begin_fill()
    t.fillcolor("black")
    t.pu()  # 提笔
    t.goto(46, 10)  # 笔头初始位置
    t.pd()  # 下笔
    t.setheading(-90)  # 画笔角度
    t.circle(5, 360)
    t.end_fill()
# 画脸
def InitFace():
    # 脸蛋
    t.begin_fill()
    t.fillcolor("red")
    t.pu()  # 提笔
    t.goto(-63, -10)  # 笔头初始位置
    t.pd()  # 下笔
    t.setheading(90)  # 画笔角度
    t.circle(10, 360)
    t.end_fill()
    t.begin_fill()
    t.fillcolor("red")
    t.pu()  # 提笔
    t.goto(63, -10)  # 笔头初始位置
    t.pd()  # 下笔
    t.setheading(-90)  # 画笔角度
    t.circle(10, 360)
    t.end_fill()
    # 嘴巴
    t.pensize(2.2)
    t.pu()  # 提笔
    t.goto(0, 0)  # 笔头初始位置
    t.pd()  # 下笔
    t.setheading(235)  # 画笔角度
    radian_right(5, 0.8, 0, 30)
    t.pu()  # 提笔
    t.goto(0, 0)  # 笔头初始位置
    t.pd()  # 下笔
    t.setheading(305)  # 画笔角度
    radian_left(5, 0.8, 0, 30)
# 画手
def InitHands():
    # 左手
    t.pensize(2)
    t.pu()  # 提笔
    t.goto(-46, -100)  # 笔头初始位置
    t.pd()  # 下笔
    t.setheading(285)  # 画笔角度
    radian_right(0.4, 1.2, 0, 26)
    radian_right(5, 0.35, 0, 26)
    radian_right(0.3, 1.2, 0, 15)
    # 右手
    t.pu()  # 提笔
    t.goto(46, -100)  # 笔头初始位置
    t.pd()  # 下笔
    t.setheading(255)  # 画笔角度
    radian_left(0.4, 1.2, 0, 26)
    radian_left(5, 0.35, 0, 26)
    radian_left(0.3, 1.2, 0, 15)
def CloseEyes():
    # 左眼睛
    t.pu()  # 提笔
    t.goto(-46, 12)  # 笔头初始位置
    t.pd()  # 下笔
    t.setheading(180)  # 画笔角度
    t.forward(10)
    # 右眼睛
    t.pu()  # 提笔
    t.goto(46, 12)  # 笔头初始位置
    t.pd()  # 下笔
    t.setheading(0)  # 画笔角度
    t.forward(10)
# 初始化
def Init():
    InitEars()
    InitTail()
    InitFoots()
    InitBody()
    InitFace()
    InitHands()
    InitEyes()
# 眨眼睛
def Upgarde():
    InitEars()
    InitTail()
    InitFoots()
    InitBody()
    InitFace()
    InitHands()
    CloseEyes()
def Upgarde_Init():
    InitEars()
    InitTail()
    InitFoots()
    InitBody()
    InitFace()
    InitHands()
    InitEyes()
def main():
    Init()
    t.tracer(False)
    # 眨眼睛动画
    for i in range(30):
        if i % 2 == 0:
            t.reset()
            t.hideturtle()
            Upgarde()
            t.update()
            time.sleep(0.3)
        else:
            t.reset()
            t.hideturtle()
            Upgarde_Init()
            t.update()
            time.sleep(1)
main()
# 结束画笔
t.done()

9. 钟表

# -*- coding:utf-8 –*-
# 用turtlr画时钟
# 以自定义shape的方式实现
import turtle as t
import datetime as d
def skip(step):  # 抬笔,跳到一个地方
    t.penup()
    t.forward(step)
    t.pendown()
def drawClock(radius):  # 画表盘
    t.speed(0)
    t.mode("logo")  # 以Logo坐标、角度方式
    t.hideturtle()
    t.pensize(7)
    t.home()  # 回到圆点
    for j in range(60):
        skip(radius)
        if (j % 5 == 0):
            t.forward(20)
            skip(-radius - 20)
        else:
            t.dot(5)
            skip(-radius)
        t.right(6)
def makePoint(pointName, len):  # 钟的指针,时针、分针、秒针
    t.penup()
    t.home()
    t.begin_poly()
    t.back(0.1 * len)
    t.forward(len * 1.1)
    t.end_poly()
    poly = t.get_poly()
    t.register_shape(pointName, poly)  # 注册为一个shape
def drawPoint():  # 画指针
    global hourPoint, minPoint, secPoint, fontWriter
    makePoint("hourPoint", 100)
    makePoint("minPoint", 120)
    makePoint("secPoint", 140)
    hourPoint = t.Pen()  # 每个指针是一只新turtle
    hourPoint.shape("hourPoint")
    hourPoint.shapesize(1, 1, 6)
    minPoint = t.Pen()
    minPoint.shape("minPoint")
    minPoint.shapesize(1, 1, 4)
    secPoint = t.Pen()
    secPoint.shape("secPoint")
    secPoint.pencolor('red')
    fontWriter = t.Pen()
    fontWriter.pencolor('gray')
    fontWriter.hideturtle()
def getWeekName(weekday):
    weekName = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日']
    return weekName[weekday]
def getDate(year, month, day):
    return "%s-%s-%s" % (year, month, day)
def realTime():
    curr = ()
    curr_year = 
    curr_month = curr.month
    curr_day = 
    curr_hour = 
    curr_minute = curr.minute
    curr_second = curr.second
    curr_weekday = curr.weekday()
    t.tracer(False)
    secPoint.setheading(360 / 60 * curr_second)
    minPoint.setheading(360 / 60 * curr_minute)
    hourPoint.setheading(360 / 12 * curr_hour + 30 / 60 * curr_minute)
    fontWriter.clear()
    ()
    fontWriter.penup()
    fontWriter.forward(80)
    # 用turtle写文字
    fontWriter.write(getWeekName(curr_weekday), align="center", font=("Courier", 14, "bold"))
    fontWriter.forward(-160)
    fontWriter.write(getDate(curr_year, curr_month, curr_day), align="center", font=("Courier", 14, "bold"))
    t.tracer(True)
    print(curr_second)
    t.ontimer(realTime, 100)  # 每隔100毫秒调用一次realTime()
def main():
    t.tracer(False)
    drawClock(160)
    drawPoint()
    realTime()
    t.tracer(True)
    t.mainloop()
if __name__ == '__main__':
    main()

10. 汉诺塔

import turtle
class Stack:
    def __init__(self):
        self.items = []
    def isEmpty(self):
        return len(self.items) == 0
    def push(self, item):
        self.items.append(item)
    def pop(self):
        return ()
    def peek(self):
        if not self.isEmpty():
            return self.items[len(self.items) - 1]
    def size(self):
        return len(self.items)
def drawpole_3():  # 画出汉诺塔的poles
    t = turtle.Turtle()
    t.hideturtle()
    def drawpole_1(k):
        t.up()
        t.pensize(10)
        t.speed(100)
        t.goto(400 * (k - 1), 100)
        t.down()
        t.goto(400 * (k - 1), -100)
        t.goto(400 * (k - 1) - 20, -100)
        t.goto(400 * (k - 1) + 20, -100)
    drawpole_1(0)  # 画出汉诺塔的poles[0]
    drawpole_1(1)  # 画出汉诺塔的poles[1]
    drawpole_1(2)  # 画出汉诺塔的poles[2]
def creat_plates(n):  # 制造n个盘子
    plates = [turtle.Turtle() for i in range(n)]
    for i in range(n):
        plates[i].up()
        plates[i].hideturtle()
        plates[i].shape("square")
        plates[i].shapesize(1, 8 - i)
        plates[i].goto(-400, -90 + 20 * i)
        plates[i].showturtle()
    return plates
def pole_stack():  # 制造poles的栈
    poles = [Stack() for i in range(3)]
    return poles
def moveDisk(plates, poles, fp, tp):  # 把poles[fp]顶端的盘子plates[mov]从poles[fp]移到poles[tp]
    mov = poles[fp].peek()
    plates[mov].goto((fp - 1) * 400, 150)
    plates[mov].goto((tp - 1) * 400, 150)
    l = poles[tp].size()  # 确定移动到底部的高度(恰好放在原来最上面的盘子上面)
    plates[mov].goto((tp - 1) * 400, -90 + 20 * l)
def moveTower(plates, poles, height, fromPole, toPole, withPole):  # 递归放盘子
    if height >= 1:
        moveTower(plates, poles, height - 1, fromPole, withPole, toPole)
        moveDisk(plates, poles, fromPole, toPole)
        poles[toPole].push(poles[fromPole].pop())
        moveTower(plates, poles, height - 1, withPole, toPole, fromPole)
myscreen = turtle.Screen()
drawpole_3()
n = int(input("请输入汉诺塔的层数并回车:\n"))
plates = creat_plates(n)
poles = pole_stack()
for i in range(n):
    poles[0].push(i)
moveTower(plates, poles, n, 0, 2, 1)
myscreen.exitonclick()

11. 高达

import turtle
t=turtle.Turtle()
turtle.Turtle().screen.delay(0)
tleft=turtle.Turtle()
#第一部分
t.penup()
t.goto(0,0)
t.pendown()
t.left(20)
t.forward(110)
t.left(25)
t.forward(40)
t.left(100)
t.circle(180,20)
t.right(120)
t.forward(250)
t.left(165)
t.forward(250)
t.right(100)
t.forward(35)
t.left(70)
t.forward(45)
t.left(70)
t.forward(120)
t.left(70)
t.forward(80)
t.left(80)
t.forward(80)
t.left(68)
t.forward(120)
t.left(180)
t.forward(78)
t.right(68)
t.forward(60)
t.right(75)
t.forward(60)
t.right(110)
t.forward(15)
t.left(38)
t.forward(65)
t.right(73)#五边形的直边
t.forward(35)
t.right(70)
t.forward(65)
t.right(68)
t.forward(50)
t.right(80)
t.forward(50)
t.penup()
t.goto(-65,68)
t.pendown()
t.right(7)
t.forward(350)
t.right(165)
t.forward(330)
t.penup()
t.goto(64,65)
t.pendown()
t.left(75)
t.forward(350)
t.left(165)
t.forward(330)
t.penup()
t.goto(300,500)
#第二部分
(180)
tleft.right(20)
tleft.forward(110)
tleft.right(25)
tleft.forward(40)
tleft.right(100)
tleft.circle(-180,20)
(120)
tleft.forward(250)
tleft.right(165)
tleft.forward(250)
(100)
tleft.forward(35)
tleft.penup()
(0,0)
tleft.pendown()
(20)
tleft.penup()
tleft.forward(18)
tleft.pendown()
tleft.forward(50)#额头竖线
tleft.penup()
tleft.forward(110)#消除竖线
tleft.pendown()
(90)
tleft.forward(30)
tleft.right(90)
tleft.forward(60)
tleft.right(90)
tleft.forward(60)
tleft.right(90)
tleft.forward(60)
tleft.right(90)
tleft.forward(40)
tleft.penup()
tleft.forward(30)
tleft.pendown()
(90)
tleft.forward(30)
tleft.right(180)
tleft.forward(100)
tleft.right(90)
tleft.forward(80)
tleft.right(90)
tleft.forward(100)
tleft.penup()
(150,70)
tleft.pendown()
(100)
tleft.forward(40)
tleft.right(80)
tleft.circle(-333,40)
tleft.right(160)
tleft.forward(230)
#右半部分
(100)
tleft.forward(40)
(80)
tleft.forward(20)
(100)
tleft.forward(30)
tleft.right(100)
tleft.forward(20)
tleft.right(80)
tleft.forward(30)
(80)
tleft.forward(20)
(100)
tleft.forward(30)
tleft.right(100)
tleft.forward(20)
tleft.right(80)
tleft.forward(30)
(80)
tleft.forward(20)
(100)
tleft.forward(30)
tleft.right(100)
tleft.forward(20)
tleft.right(80)
tleft.forward(30)
(80)
tleft.forward(20)
(100)
tleft.forward(30)
tleft.right(100)
tleft.forward(20)
tleft.right(80)
tleft.forward(30)
(80)
tleft.forward(20)
(100)
tleft.forward(30)
tleft.right(100)
tleft.forward(20)
tleft.right(80)
tleft.forward(30)
(80)
tleft.forward(20)
(100)
tleft.forward(30)
tleft.right(100)
tleft.forward(20)
tleft.right(80)
tleft.forward(30)
#右下部分
(70)
tleft.forward(30)
tleft.right(110)
tleft.forward(40)
tleft.right(60)
tleft.forward(100)
tleft.right(30)
tleft.circle(200,20)
(10)
tleft.forward(80)
#右下部分goto
tleft.penup()
(145,-198)
tleft.pendown()
(90)
tleft.forward(30)
tleft.right(30)
tleft.forward(40)
tleft.right(150)
tleft.forward(30)
tleft.backward(30)
(90)
tleft.forward(100)
tleft.right(90)
tleft.forward(30)
tleft.backward(30)
(90)
tleft.right(30)
tleft.circle(200,20)
(10)
tleft.forward(50)
#第三部分脸
t2=turtle.Turtle()
t2.penup()
(0,-80)
#尖角
t2.circle(150,extent=90)
t2.pendown()
t2.circle(150,extent=30)
t2.penup()
t2.circle(150,extent=18)
t2.pendown()
t2.circle(150,extent=27)
t2.penup()
t2.circle(150,extent=30)
t2.pendown()
t2.circle(150,extent=27)
t2.penup()
t2.circle(150,extent=18)
t2.pendown()
t2.circle(150,extent=30)
t2.right(100)
t2.forward(40)
#左脸夹
(80)
t2.circle(333,40)
(160)
t2.forward(230)
#左半部分
t2.right(100)
t2.forward(40)
t2.right(80)
t2.forward(20)
t2.right(100)
t2.forward(30)
(100)
t2.forward(20)
(80)
t2.forward(30)
t2.right(80)
t2.forward(20)
t2.right(100)
t2.forward(30)
(100)
t2.forward(20)
(80)
t2.forward(30)
t2.right(80)
t2.forward(20)
t2.right(100)
t2.forward(30)
(100)
t2.forward(20)
(80)
t2.forward(30)
t2.right(80)
t2.forward(20)
t2.right(100)
t2.forward(30)
(100)
t2.forward(20)
(80)
t2.forward(30)
t2.right(80)
t2.forward(20)
t2.right(100)
t2.forward(30)
(100)
t2.forward(20)
(80)
t2.forward(30)
t2.right(80)
t2.forward(20)
t2.right(100)
t2.forward(30)
(100)
t2.forward(20)
(80)
t2.forward(30)
t2.right(70)
t2.forward(30)
(110)
t2.forward(40)
(60)
t2.forward(100)
(30)
t2.circle(-200,20)
t2.right(10)
t2.forward(80)
t2.penup()
(-145,-198)#左脸颊
t2.pendown()
t2.right(90)
t2.forward(30)
(30)
t2.forward(40)
(150)
t2.forward(30)
t2.right(180)
t2.forward(30)
(90)
t2.forward(100)
(90)
t2.forward(30)
(180)
t2.forward(30)
(120)
t2.circle(-200,20)
t2.right(10)
t2.forward(50)
#左眼
t2.right(135)
t2.forward(70)
(50)
t2.forward(40)
(20)
t2.forward(20)
t2.penup()
(-100,28)
t2.pendown()
t2.right(70)
t2.forward(65)
(50)
t2.forward(40)
(40)
t2.forward(20)
#左眼带
t2.penup()
(-105,-10)
t2.pendown()
t2.right(100)
t2.circle(120,extent=20)
t2.circle(60,extent=80)
t2.penup()
(-105,-13)
t2.pendown()
t2.right(100)
t2.circle(120,extent=20)
t2.circle(60,extent=80)
t2.penup()
(-70,-40)
t2.pendown()
(10)
t2.forward(30)
t2.penup()
(-10,-40)
t2.pendown()
(35)
t2.forward(30)
t2.penup()
(-80,30)
t2.pendown()
t2.right(130)
t2.forward(47)
(50)
t2.forward(35)
t2.penup()
(-60,-45)
t2.pendown()
t2.right(98)
t2.forward(60)
(20)
t2.forward(80)
(70)
t2.forward(10)
(90)
t2.forward(50)
t2.right(60)
t2.forward(30)
t2.right(60)
t2.forward(30)
t2.right(60)
t2.forward(50)
(90)
t2.forward(10)
(75)
t2.forward(80)
(15)
t2.forward(60)
t2.penup()
(-80,-140)
t2.pendown()
t2.right(150)
t2.circle(85,extent=45)
(15)
t2.forward(70)
(15)
t2.circle(55,extent=55)
t2.penup()
(0,-175)
t2.pendown()
(18)
t2.forward(170)
#右眼
(135)
tleft.forward(70)
tleft.right(50)
tleft.forward(40)
tleft.right(20)
tleft.forward(20)
tleft.penup()
(100,28)
tleft.pendown()
(70)
tleft.forward(65)
tleft.right(50)
tleft.forward(40)
tleft.right(40)
tleft.forward(20)
#右眼带
tleft.penup()
(105,-10)
tleft.pendown()
(100)
tleft.circle(-120,extent=20)
tleft.circle(-60,extent=80)
tleft.penup()
(105,-13)
tleft.pendown()
(100)
tleft.circle(-120,extent=20)
tleft.circle(-60,extent=80)
#右眼睛
tleft.penup()
(70,-40)
tleft.pendown()
tleft.right(10)
tleft.forward(30)
tleft.penup()
(10,-40)
tleft.pendown()
tleft.right(35)
tleft.forward(30)
tleft.penup()
(80,30)
tleft.pendown()
(130)
tleft.forward(47)
tleft.right(50)
tleft.forward(35)
#鼻子
tleft.penup()
(0,-70)
tleft.pendown()
(30)
tleft.forward(20)
(72)
tleft.forward(10)
(108)
tleft.forward(20)
tleft.right(42)
tleft.forward(20)
(108)
tleft.forward(10)
(72)
tleft.forward(20)
tleft.penup()
(0,-90)
tleft.pendown()
(42)
tleft.forward(20)
(72)
tleft.forward(10)
(108)
tleft.forward(20)
tleft.right(42)
tleft.forward(20)
(108)
tleft.forward(10)
(72)
tleft.forward(20)
tleft.penup()
(200,500)
()

13. 星空

from turtle import *
from random import random,randint
screen = Screen()
width ,height = 800,600
screen.setup(width,height)
screen.bgcolor("black")
("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(-height/2,height/2))
stars = []
for i in range(200):
    star = t.clone()
    s =random() /3
    star.shapesize(s,s)
    star.speed(int(s*10))
    (width/2 + randint(1,width))
    ( randint(-height/2,height/2))
    star.showturtle()
    stars.append(star)
while True:
    for star in stars:
        (() - 3 * star.speed())
        if ()<-width/2:
            star.hideturtle()
            (width/2 + randint(1,width))
            ( randint(-height/2,height/2))
            star.showturtle()

14. 狮子头

import turtle as t
def hair():  # 画头发
    t.penup()
    t.goto(-50, 150)
    t.pendown()
    t.fillcolor('#a2774d')
    t.begin_fill()
    for j in range(10):  # 重复执行10次
        t.setheading(60 - (j * 36))  # 每次调整初始角度
        t.circle(-50, 120)  # 画120度的弧
    t.end_fill()
def face():  # 画脸
    t.penup()
    t.goto(0, 100)
    t.pendown()
    t.fillcolor('#f2ae20')
    t.begin_fill()
    t.setheading(180)
    t.circle(85)
    t.end_fill()
    # 下巴
    t.circle(85, 120)
    t.fillcolor('white')
    t.begin_fill()
    t.circle(85, 120)
    t.setheading(135)
    t.circle(100, 95)
    t.end_fill()
def ears(dir):  # 画眼睛,dir用来设置方向,左右眼对称
    t.penup()
    t.goto((0 - dir) * 30, 90)
    t.setheading(90)
    t.pendown()
    t.fillcolor('#f2ae20')
    t.begin_fill()
    t.circle(dir * 30)
    t.end_fill()
    t.penup()
    t.goto((0 - dir) * 40, 85)
    t.setheading(90)
    t.pendown()
    t.fillcolor('white')
    t.begin_fill()
    t.circle(dir * 17)
    t.end_fill()
def nose():  # 画鼻子
    t.penup()
    t.goto(20, 0)
    t.setheading(90)
    t.pendown()
    t.fillcolor('#a2774d')
    t.begin_fill()
    t.circle(20)
    t.end_fill()
def eye(dir):  # 画耳朵,dir用来设置方向,左右耳对称
    t.penup()
    t.goto((0 - dir) * 30, 20)
    t.setheading(0)
    t.pendown()
    t.fillcolor('black')
    t.begin_fill()
    t.circle(10)
    t.end_fill()
def mouth():  # 画嘴巴
    t.penup()
    t.goto(0, 0)
    t.setheading(-90)
    t.pendown()
    t.forward(50)
    t.setheading(0)
    t.circle(80, 30)
    t.penup()
    t.goto(0, -50)
    t.setheading(180)
    t.pendown()
    t.circle(-80, 30)
hair()
ears(1)
ears(-1)
face()
eye(1)
eye(-1)
mouth()
nose()
t.done()

16. 我太难了

import turtle
# 画指定的任意圆弧
def arc(sa, ea, x, y, r):  # start angle,end angle,circle center,radius
    turtle.penup()
    (x, y)
    eading(0)
    (sa)
    (r)
    turtle.pendown()
    (90)
    turtle.circle(r, (ea - sa))
    return turtle.position()
turtle.hideturtle()
# 画脸
turtle.speed(5)
turtle.setup(900, 600, 200, 200)
turtle.pensize(5)
turtle.right(90)
turtle.penup()
(100)
(90)
turtle.pendown()
turtle.begin_fill()
turtle.pencolor("#B26A0F")  # head side color
turtle.circle(150)
turtle.fillcolor("#F9E549")  # face color
turtle.end_fill()
# 画嘴
turtle.penup()
(77, 20)
turtle.pencolor("#744702")
(0, 50)
turtle.right(30)
(110)
turtle.right(90)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor("#925902")  # mouth color
turtle.circle(-97, 160)
(92, -3)
turtle.end_fill()
turtle.penup()
(77, -25)
# 画牙齿
turtle.pencolor("white")
turtle.begin_fill()
turtle.fillcolor("white")
(77, -24)
(-81, 29)
(-70, 43)
(77, -8)
turtle.end_fill()
turtle.penup()
(0, -100)
eading(0)
turtle.pendown()
# 画左边眼泪
(90)
turtle.penup()
(150)
turtle.right(60)
(-150)
turtle.pendown()
(20)
turtle.pencolor("#155F84")  # tear side color
(150)
turtle.right(180)
position1 = turtle.position()
turtle.begin_fill()
turtle.fillcolor("#7EB0C8")  # tear color
(150)
turtle.right(20)
(270)
turtle.circle(-150, 18)
turtle.right(52)
(110)
position2 = turtle.position()
(-33, 90)
turtle.end_fill()
# 画右边眼泪
turtle.penup()
(0, 0)
eading(0)
(90)
(50)
turtle.right(150)
(150)
(150)
(100)
turtle.pendown()
turtle.begin_fill()
(-100)
turtle.fillcolor("#7EB0C8")  # tear color
turtle.right(60)
turtle.circle(150, 15)
(45)
(66)
(77, 20)
turtle.end_fill()
# 画眼睛
turtle.penup()
turtle.pencolor("#6C4E00")  # eye color
(-65, 75)
eading(0)
(27)
(38)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor("#6C4E00")  # eye color
(90)
turtle.circle(38, 86)
(position2[0], position2[1])
(position1[0], position1[1])
turtle.end_fill()
# 画手
turtle.pencolor("#D57E18")  # hand side color
turtle.begin_fill()
turtle.fillcolor("#EFBD3D")  # hand color
# 第一个手指
arc(-110, 10, 110, -40, 30)
turtle.circle(300, 35)
turtle.circle(13, 120)
eading(-50)
(20)
eading(130)
# 第二个手指
turtle.circle(200, 15)
turtle.circle(12, 180)
(40)
eading(137)
# 第三个手指
turtle.circle(200, 16)
turtle.circle(12, 160)
eading(-35)
(45)
eading(140)
# 第四个手指
turtle.circle(200, 13)
turtle.circle(11, 160)
eading(-35)
(40)
eading(145)
# 第五个手指
turtle.circle(200, 9)
turtle.circle(10, 180)
eading(-31)
(50)
# 画最后手腕的部分
eading(-45)
turtle.pensize(7)
turtle.right(5)
turtle.circle(180, 35)
turtle.end_fill()
turtle.begin_fill()
eading(-77)
turtle.pensize(5)
(50)
(-270)
(7)
turtle.pencolor("#EFBD3D")
turtle.circle(30, 180)
turtle.end_fill()
# 测试
# res=arc(70,220,90,50,300)
# print(res[0],res[1])
()

17. 如果让你重新来过,你会不会爱我


import turtle as t
# t = ()
t.bgcolor("black")
sides=eval(input("输入要绘制的边的数目,请输入2-6的数字!"))
colors=["red","yellow","green","blue","orange","purple"]
for x in range(150):
    t.pencolor(colors[x%sides])
    t.forward(x*3/sides+x)
    t.left(360/sides+1)
    t.width(x*sides/200)
t.exitonclick()
print("####结束####")

18. 数码管时间

import turtle as t
import datetime
def drawGap(): #绘制数码管间隔
    t.penup()
    t.fd(5)
def drawLine(draw):   #绘制单段数码管
    drawGap()
    t.pendown() if draw else t.penup()
    t.fd(40)
    drawGap()
    t.right(90)
def drawDigit(d): #根据数字绘制七段数码管
    drawLine(True) if d in [2,3,4,5,6,8,9] else drawLine(False)
    drawLine(True) if d in [0,1,3,4,5,6,7,8,9] else drawLine(False)
    drawLine(True) if d in [0,2,3,5,6,8,9] else drawLine(False)
    drawLine(True) if d in [0,2,6,8] else drawLine(False)
    t.left(90)
    drawLine(True) if d in [0,4,5,6,8,9] else drawLine(False)
    drawLine(True) if d in [0,2,3,5,6,7,8,9] else drawLine(False)
    drawLine(True) if d in [0,1,2,3,4,7,8,9] else drawLine(False)
    t.left(180)
    t.penup()
    t.fd(20)
def drawDate(date):
    t.pencolor("red")
    for i in date:
        if i == '-':
            t.write('年', font=("Arial", 18, "normal"))
            t.pencolor("green")
            t.fd(40)
        elif i == '=':
            t.write('月', font=("Arial", 18, "normal"))
            t.pencolor("blue")
            t.fd(40)
        elif i == '+':  
            t.write('日', font=("Arial", 18, "normal"))
        else:
            drawDigit(eval(i))
def main():
    t.setup(800, 350, 200, 200)
    t.penup()
    t.fd(-350)
    t.pensize(5)
    drawDate(().strftime('%Y-%m=%d+'))
    t.hideturtle()
    t.exitonclick()
main()

20. 永远滴神

from turtle import *
import turtle as t
t.screensize(500, 500)
# 【头部轮廓】
t.pensize(5)
t.home()
t.seth(0)
t.pd()
t.color('black')
t.circle(20, 80)  # 0
t.circle(200, 30)  # 1
t.circle(30, 60)  # 2
t.circle(200, 29.5)  # 3
t.color('black')
t.circle(20, 60)  # 4
t.circle(-150, 22)  # 5
t.circle(-50, 10)  # 6
t.circle(50, 70)  # 7
# 确定鼻头大概位置
x_nose = t.xcor()
y_nose = t.ycor()
t.circle(30, 62)  # 8
t.circle(200, 15)  # 9
# 【鼻子】
t.pu()
t.goto(x_nose, y_nose + 25)
t.seth(90)
t.pd()
t.begin_fill()
t.circle(8)
t.end_fill()
# 【眼睛】
t.pu()
t.goto(x_nose + 48, y_nose + 55)
t.seth(90)
t.pd()
t.begin_fill()
t.circle(8)
t.end_fill()
# 【耳朵】
t.pu()
t.color('#444444')
t.goto(x_nose + 100, y_nose + 110)
t.seth(182)
t.pd()
t.circle(15, 45)  # 1
t.color('black')
t.circle(10, 15)  # 2
t.circle(90, 70)  # 3
t.circle(25, 110)  # 4
t.rt(4)
t.circle(90, 70)  # 5
t.circle(10, 15)  # 6
t.color('#444444')
t.circle(15, 45)  # 7
# 【身体】
t.pu()
t.color('black')
t.goto(x_nose + 90, y_nose - 30)
t.seth(-130)
t.pd()
t.circle(250, 28)  # 1
t.circle(10, 140)  # 2
t.circle(-250, 25)  # 3
t.circle(-200, 25)  # 4
t.circle(-50, 85)  # 5
t.circle(8, 145)  # 6
t.circle(90, 45)  # 7
t.circle(550, 5)  # 8
# 【尾巴】
t.seth(0)
t.circle(60, 85)  # 1
t.circle(40, 65)  # 2
t.circle(40, 60)  # 3
t.lt(150)
t.circle(-40, 90)  # 4
t.circle(-25, 100)  # 5
t.lt(5)
t.fd(20)
t.circle(10, 60)  # 6
# 【背部】
t.rt(80)
t.circle(200, 35)
# 【项圈】
t.pensize(20)
t.color('#F03C3F')
t.lt(10)
t.circle(-200, 25)  # 5
# 【爱心铃铛】
t.pu()
t.fd(18)
t.lt(90)
t.fd(18)
t.pensize(6)
t.seth(35)
t.color('#FDAF17')
t.begin_fill()
t.lt(135)
t.fd(6)
t.right(180)  # 画笔掉头
t.circle(6, -180)
t.backward(8)
t.right(90)
t.forward(6)
t.circle(-6, 180)
t.fd(15)
t.end_fill()
# 【前小腿】
t.pensize(5)
t.pu()
t.color('black')
t.goto(x_nose + 100, y_nose - 125)
t.pd()
t.seth(-50)
t.fd(25)
t.circle(10, 150)
t.fd(25)
# 【后小腿】
t.pensize(4)
t.pu()
t.goto(x_nose + 314, y_nose - 125)
t.pd()
t.seth(-95)
t.fd(25)
t.circle(-5, 150)
t.fd(2)
t.hideturtle()
t.done()

21. I了I了

import turtle as t
from time import sleep
def go_to(x, y):
    t.up()
    t.goto(x, y)
    t.down()
def head(x, y, r):
    go_to(x, y)
    t.speed(20)
    t.circle(r)
    leg(x, y)
def leg(x, y):
    t.right(90)
    t.forward(180)
    t.right(30)
    t.forward(100)
    t.left(120)
    go_to(x, y - 180)
    t.forward(100)
    t.right(120)
    t.forward(100)
    t.left(120)
    hand(x, y)
def hand(x, y):
    go_to(x, y - 60)
    t.forward(100)
    t.left(60)
    t.forward(100)
    go_to(x, y - 90)
    t.right(60)
    t.forward(100)
    t.right(60)
    t.forward(100)
    t.left(60)
    eye(x, y)
def eye(x, y):
    go_to(x - 50, y + 130)
    t.right(90)
    t.forward(50)
    go_to(x + 40, y + 130)
    t.forward(50)
    t.left(90)
def big_Circle(size):
    t.speed(20)
    for i in range(150):
        t.forward(size)
        t.right(0.3)
def line(size):
    t.speed(20)
    t.forward(51 * size)
def small_Circle(size):
    t.speed(20)
    for i in range(210):
        t.forward(size)
        t.right(0.786)
def heart(x, y, size):
    go_to(x, y)
    t.left(150)
    t.begin_fill()
    line(size)
    big_Circle(size)
    small_Circle(size)
    t.left(120)
    small_Circle(size)
    big_Circle(size)
    line(size)
    t.end_fill()
def main():
    t.pensize(2)
    t.color('red', 'pink')
    head(-120, 100, 100)
    heart(250, -80, 1)
    go_to(100, -300)
    t.write("To: 智慧与美貌并存的", move=True, align="left", font=("楷体", 20, "normal"))
    t.done()
main()

22. 胖达

import turtle as t

t.title("熊猫宝宝")
t.shape("classic")
t.pensize(3)
t.color("black")
t.fillcolor("black")
t.speed(100)
t.hideturtle()
#左耳
t.penup()
t.goto(-105,97)
t.setheading(160)
t.begin_fill()
t.pendown()
t.circle(-30,230)
t.setheading(180)
t.circle(37,90)
t.end_fill()
#右耳
t.penup()
t.goto(105,97)
t.setheading(20)
t.begin_fill()
t.pendown()
t.circle(30,230)
t.setheading(0)
t.circle(-37,90)
t.end_fill()
#头部轮廓
t.penup()
t.goto(-67,140)
t.setheading(30)
t.pendown()
t.circle(-134,60)

t.penup()
t.goto(-50,-25)
t.setheading(180)
t.pendown()
t.circle(-100,30)
t.circle(-30,90)
t.setheading(100)
t.circle(-200,20)

t.penup()
t.goto(50,-25)
t.setheading(0)
t.pendown()
t.circle(100,30)
t.circle(30,90)
t.setheading(80)
t.circle(200,20)

#两熊猫眼
#左眼
t.penup()
t.goto(-90,25)
t.setheading(-45)
t.begin_fill()
t.pendown()
#椭圆绘制技巧
a = 0.2
for i in range(120):
    if 0<=i<30 or 60<=i<90:
        a=a+0.1
        t.lt(3) #向左转3度
        t.fd(a) #向前走a的步长
    else:
        a=a-0.1
        t.lt(3)
        t.fd(a)
t.end_fill()

t.fillcolor("white")
t.penup()
t.goto(-53,43)
t.setheading(0)
t.begin_fill()
t.pendown()
t.circle(13,360)
t.end_fill()

t.penup()
t.pensize(4)
t.goto(-60,57)
t.setheading(30)
t.pendown()
t.circle(-12,60)
#右眼
t.penup()
t.goto(90,25)
t.setheading(45)
t.pensize(2)
t.fillcolor("black")
t.begin_fill()
t.pendown()
#椭圆绘制技巧
a = 0.2
for i in range(120):
    if 0<=i<30 or 60<=i<90:
        a=a+0.1
        t.lt(3) #向左转3度
        t.fd(a) #向前走a的步长
    else:
        a=a-0.1
        t.lt(3)
        t.fd(a)
t.end_fill()

t.fillcolor("white")
t.penup()
t.goto(53,43)
t.setheading(0)
t.begin_fill()
t.pendown()
t.circle(13,360)
t.end_fill()

t.penup()
t.pensize(4)
t.goto(60,57)
t.setheading(150)
t.pendown()
t.circle(12,60)

#鼻子和嘴吧
t.penup()
t.goto(-16,20)
t.setheading(-90)
t.fillcolor("black")
t.begin_fill()
t.pendown()
a = 0.2
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a = a + 0.03
        t.lt(3)
        t.fd(a)
    else:
        a = a - 0.03
        t.lt(3)
        t.fd(a)
t.end_fill()

t.penup()
t.goto(-24,0)
t.setheading(-60)
t.pendown()
t.circle(28,120)

#熊肢体
#左肢
t.penup()
t.goto(-65,-24)
t.setheading(-140)
t.begin_fill()
t.pendown()
t.circle(100,40)
t.setheading(180)
t.circle(30,40)
t.setheading(-40)
t.circle(40,40)
t.setheading(-150)
a = 0.5
for i in range(120):
    if 0<=i<30 or 60<=i<90:
        a=a+0.05
        t.lt(3) #向左转3度
        t.fd(a) #向前走a的步长
    elif 30 <= i < 60 or 90<=i <100:
        a=a-0.05
        t.lt(3)
        t.fd(a)
t.setheading(93)
t.circle(-150,30)
t.end_fill()

t.penup()
t.goto(-85,-115)
t.setheading(-150)
t.color("gray","gray")
t.begin_fill()
t.pendown()
a = 0.3
for i in range(120):
    if 0<=i<30 or 60<=i<90:
        a=a+0.03
        t.lt(3) #向左转3度
        t.fd(a) #向前走a的步长
    else:
        a=a-0.03
        t.lt(3)
        t.fd(a)
t.end_fill()
#每个脚趾绘制函数
def toe(x,y):
    t.begin_fill()
    t.goto(x,y)
    t.circle(3,360)
    t.end_fill()

t.penup()
toe(-98,-120)
toe(-96,-110)
toe(-88,-105)
toe(-80,-105)

#右肢
t.color("black")
t.penup()
t.goto(65,-24)
t.setheading(-40)
t.begin_fill()
t.pendown()
t.circle(-100,40)
t.setheading(0)
t.circle(-30,40)
t.setheading(-140)
t.circle(-40,40)
t.setheading(-30)
a = 0.5
for i in range(120):
    if 0<=i<30 or 60<=i<90:
        a=a+0.05
        t.rt(3) #向左转3度
        t.fd(a) #向前走a的步长
    elif 30 <= i < 60 or 90<=i <100:
        a=a-0.05
        t.rt(3)
        t.fd(a)
t.setheading(87)
t.circle(150,30)
t.end_fill()

t.penup()
t.goto(85,-115)
t.setheading(150)
t.color("gray","gray")
t.begin_fill()
t.pendown()
a = 0.3
for i in range(120):
    if 0<=i<30 or 60<=i<90:
        a=a+0.03
        t.lt(3) #向左转3度
        t.fd(a) #向前走a的步长
    else:
        a=a-0.03
        t.lt(3)
        t.fd(a)
t.end_fill()

t.penup()
toe(98,-120)
toe(96,-110)
toe(88,-105)
toe(80,-105)

t.goto(-57,-140)
t.color("black")
t.setheading(-20)
t.pendown()
t.circle(165,40)

t.penup()
t.goto(0,180)
t.write("Zuo baby is the most lovely girl", align = "center"
        , font = ("Times", 18, "bold"))
t.done()

23.  给女票的小爱心

import turtle
import time
Name=['Z','J','H']
def draw_circle():
    for i in range (200):
        turtle.right(1)
        turtle.forward(1)
def draw_love():
    turtle.color('red','pink')
    turtle.pensize(2)
    turtle.speed(10)
    (0,0)
    turtle.begin_fill()
    (140)
    turtle.forward(112)
    draw_circle()
    (120)
    draw_circle()
    turtle.forward(112)
    turtle.end_fill()
def draw_name():
    turtle.pensize(50)
    ()
    (-50,142.7)

    (100,-10)
    turtle.write("I Love you")
    ()


draw_love()
draw_name()
turtle.exitonclick()

25. 丘比特之箭

from turtle import*
import  turtle
turtle.setup(750,500)
turtle.penup()
turtle.pensize(25)
turtle.pencolor("pink")
(-230)
(90)
turtle.pendown()
turtle.circle(-50,180)
turtle.circle(50,-180)
turtle.circle(75,-50)
turtle.circle(-190,-45)
turtle.penup()
(185)
(180)
(120)
(90)
turtle.pendown()
turtle.circle(-75,-50)
turtle.circle(190,-45)
turtle.penup()
(184)
(0)
(80)
(90)
turtle.pendown()
turtle.circle(-50,180)
turtle.circle(50,-180)
turtle.circle(75,-50)
turtle.circle(-190,-45)
turtle.penup()
(185)
(180)
(120)
(90)
turtle.pendown()
turtle.circle(-75,-50)
turtle.circle(190,-45)
turtle.penup()
(150)
(180)
(300)
turtle.pencolor("red")
turtle.pensize(10)
turtle.pendown()
(-500)
(90)
(30)
(-60)
(30)
(60)
(150)
(60)
()

27.  雪花

# -*- coding: utf-8 -*-
"""
Created on Fri Jan 12 14:35:14 2018

@author: Administrator
"""

from turtle import *
import turtle as T
from random import *

def ground():
    T.hideturtle()
    T.speed(100)
    for i in range(400):
        T.pensize(randint(5,10))
        x=randint(-400,350)
        y=randint(-280,-1)
        r=-y/280
        g=-y/280
        b=-y/280
        T.pencolor(r,g,b)
        T.penup()
        T.goto(x,y)
        T.pendown()
        T.forward(randint(40,100))

def snow():
    T.hideturtle()
    T.speed(100)
    T.pensize(2)
    for i in range(100):
        r=random()
        g=random()
        b=random()
        T.pencolor(r,g,b)
        T.penup()
        T.setx(randint(-350,350))
        T.sety(randint(1,270))
        T.pendown()
        dens=randint(8,12)
        snowsize=randint(10,14)
        for j in range(dens):
            T.forward(snowsize)
            T.backward(snowsize)
            T.right(360/dens)

def main():
    T.setup(800, 600, 0, 0)
    T.tracer(False)
    T.bgcolor("black")
    snow()
    ground()
    T.tracer(True)
    T.mainloop()
main()

29. 五星红旗

import turtle
import math

turtle.pensize(1)
()
(90)
turtle.forward(200)
(90)
turtle.forward(300)
()
turtle.color("red")
turtle.begin_fill()
for i in range(2):
    (90)
    turtle.forward(400)
    (90)
    turtle.forward(600)
turtle.end_fill()
()
(90)
turtle.forward(100)
(90)
turtle.forward(100)
(90)
turtle.forward(60)
()
# 大五角星
turtle.color("yellow")
turtle.right(162)


def paint1():
    turtle.begin_fill()
    l = (60 * (math.radians(18))) / (1 + (math.radians(18)))
    for i in range(5):
        turtle.forward(l)
        (72)
        turtle.forward(l)
        turtle.right(144)
    turtle.end_fill()


paint1()


# 画五角星
def paint2():
    turtle.right(162)
    turtle.begin_fill()
    l = (20 * (math.radians(18))) / (1 + (math.radians(18)))
    for i in range(5):
        turtle.forward(l)
        (72)
        turtle.forward(l)
        turtle.right(144)
    turtle.end_fill()


def paint3():
    turtle.right(72)
    turtle.begin_fill()
    l = (20 * (math.radians(18))) / (1 + (math.radians(18)))
    for i in range(5):
        turtle.forward(l)
        (72)
        turtle.forward(l)
        turtle.right(144)
    turtle.end_fill()


def paint4():
    (18)
    turtle.begin_fill()
    l = (20 * (math.radians(18))) / (1 + (math.radians(18)))
    for i in range(5):
        turtle.forward(l)
        (72)
        turtle.forward(l)
        turtle.right(144)
    turtle.end_fill()


# 第一个小五角星
()
(72)
turtle.forward(120)
()
paint2()
# 第二个小五角星
()
(162)
turtle.forward(20)
turtle.right(90)
turtle.forward(40)
turtle.right(math.degrees((1 / 7)))
turtle.forward(20)
()
paint2()
# 第三个小五角星
()
(180 - math.degrees((1 / 7)))
turtle.forward(20)
(90)
turtle.forward(20 * (1 / 7))
()
paint3()
# 第四个小五角星
()
turtle.right(18)
turtle.forward(60)
turtle.right(90)
turtle.forward(20)
()
paint4()
turtle.color("red")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值