-
2020-10-29 21:48:48
你的程序是否编译成功,下面是绘制机器猫的完整代码,如果出现错误,请及时与正确代码进行对照修改:
机器猫的完整代码:
from turtle import *
def drawRound(size,filled): #绘制圆形
pendown()
if filled==True: #判断是否填充颜色
begin_fill()
setheading(180)
circle(size,360)
if filled==True:
end_fill()
def drawRect(length,width,filled): #绘制矩形
setheading(0)
pendown()
if filled==True:
begin_fill()
forward(length)
right(90)
forward(width)
right(90)
forward(length)
right(90)
forward(width)
if filled==True:
end_fill()
def head(): #头
#画个蓝色的大圆
color("blue","blue")
penup()
goto(0,100)
drawRound(75,True)
#画个白色的小圆
color("white","white")
penup()
goto(0,72)
drawRound(60,True)
def eyes(): #眼睛
#左眼眶
color("black","white")
penup()
goto(-15,80)
drawRound(17,True)
#右眼眶
color("black","white")
penup()
goto(19,80)
drawRound(17,True)
#左眼珠
color("black","black")
penup()
goto(-8,70)
drawRound(6,True)
color("white","white")
penup()
goto(-8,66)
drawRound(2,True)
#右眼珠
color("black","black")
penup()
goto(12,70)
drawRound(6,True)
color("white","white")
penup()
goto(12,66)
drawRound(2,True)
def nose(): #鼻子
color("red","red")
penup()
goto(0,40)
drawRound(7,True)
def mouth(): #嘴巴
#嘴
color("black","black")
penup()
goto(-30,-20)
pendown()
setheading(-27)
circle(70,55)
#人中
penup()
goto(0,26)
pendown()
goto(0,-25)
def whiskers(): #胡须
color("black","black")
#左边中间的胡子
penup()
goto(10,5)
pendown()
goto(-40,5)
#右边中间的胡子
penup()
goto(10,5)
pendown()
goto(40,5)
#左上的胡子
penup()
goto(-10,15)
pendown()
goto(-40,20)
#右上的胡子
penup()
goto(10,15)
pendown()
goto(40,20)
#左下的胡子
penup()
goto(-10,-5)
pendown()
goto(-40,-10)
#右下的胡子
penup()
goto(10,-5)
pendown()
goto(40,-10)
def body(): #身体
#蓝色的身体
color("blue","blue")
penup()
goto(-50,-40)
drawRect(100,80,True)
#白色的大肚子
color("white","white")
penup()
goto(0,-30)
drawRound(40,True)
#红色丝带
color("red","red")
penup()
goto(-60,-35)
drawRect(120,10,True)
#白色的腿
color("white","white")
penup()
goto(15,-127)
pendown()
begin_fill()
setheading(90)
circle(14,180)
end_fill()
def feet(): #脚
#左脚
color("black","white")
penup()
goto(-30,-110)
drawRound(20,True)
#右脚
color("black","white")
penup()
goto(30,-110)
drawRound(20,True)
def arms(): #胳膊
#左胳膊
color("blue","blue")
penup()
begin_fill()
goto(-51,-50)
pendown()
goto(-51,-75)
left(70)
goto(-76,-85)
left(70)
goto(-86,-70)
left(70)
goto(-51,-50)
end_fill()
#右胳膊
color("blue","blue")
penup()
begin_fill()
goto(49,-50)
pendown()
goto(49,-75)
left(70)
goto(74,-85)
left(70)
goto(84,-70)
left(70)
goto(49,-50)
end_fill()
def hands(): #手
#左手
color("black","white")
penup()
goto(-90,-71)
drawRound(15,True)
#右手
color("black","white")
penup()
goto(90,-71)
drawRound(15,True)
def bell(): #铃铛
#黄色实心圆表示铜铃
color("yellow","yellow")
penup()
goto(0,-41)
drawRound(8,True)
#黑色矩形表示花纹
color("black","black")
penup()
goto(-10,-47)
drawRect(20,4,False)
#黑色实心圆表示撞击的金属丸
color("black","black")
penup()
goto(0,-53)
drawRound(2,True)
def package(): #口袋
#半圆
color("black","black")
penup()
goto(-25,-70)
pendown()
setheading(-90)
circle(25,180)
goto(-25,-70)
hideturtle()
#设置窗口大小
setup(500,500)
#设置画笔
speed(10)
#shape("turtle")
colormode(255)
#绘制机器猫
head() #头
eyes() #眼睛
nose() #鼻子
mouth() #嘴
whiskers() #胡子
body() #身体
feet() #脚
arms() #胳膊
hands() #手
bell() #铃铛
package() #口袋
更多相关内容 -
turtle作图作品
2018-06-25 17:56:08利用python3标准turtle库制作的图片, 参观 绘图方式和Pygame有很大不同,Pygame是通过场景与场景的快速变换体现事物的变化,而Turtle更像我们生活中的绘画,每一画依次完成。假设一个机器人在(0,0),我们对其有各种... -
python创意turtle作品和代码-艺术和代码的结合 turtle + python 的结合
2020-10-29 21:49:161.环境pip install turtal如果安装失败:1.1 wget turtal的下载地址,自行解压...你的下载turtle路径"。2. 当导包turtal时,报错如下File "/usr/lib/python3.6/turtle.py", line 107, in import tki...1.环境
pip install turtal
如果安装失败:
1.1 wget turtal的下载地址,自行解压, 按照提示更改, 更改完成--> pip install -e "你的下载turtle路径"。
2. 当导包turtal时,报错如下
File "/usr/lib/python3.6/turtle.py", line 107, in
import tkinter as TK
ModuleNotFoundError: No module named 'tkinter'
解决方案:
sudo apt-get update
sudo apt-get install tcl-dev tk-dev python3-tk
2. 参考案例--(资源收集于网络)
2.0 多边形(几行代码实现)
import turtle
t = turtle.Pen()
for x in range(360):
t.forward(x)
t.left(59)
2.1 花
import turtle
# 设置初始位置
turtle.penup()
turtle.left(90)
turtle.fd(200)
turtle.pendown()
turtle.right(90)
# 花蕊
turtle.fillcolor("red")
turtle.begin_fill()
turtle.circle(10, 180)
turtle.circle(25, 110)
turtle.left(50)
turtle.circle(60, 45)
turtle.circle(20, 170)
turtle.right(24)
turtle.fd(30)
turtle.left(10)
turtle.circle(30, 110)
turtle.fd(20)
turtle.left(40)
turtle.circle(90, 70)
turtle.circle(30, 150)
turtle.right(30)
turtle.fd(15)
turtle.circle(80, 90)
turtle.left(15)
turtle.fd(45)
turtle.right(165)
turtle.fd(20)
turtle.left(155)
turtle.circle(150, 80)
turtle.left(50)
turtle.circle(150, 90)
turtle.end_fill()
# 花瓣1
turtle.left(150)
turtle.circle(-90, 70)
turtle.left(20)
turtle.circle(75, 105)
turtle.setheading(60)
turtle.circle(80, 98)
turtle.circle(-90, 40)
# 花瓣2
turtle.left(180)
turtle.circle(90, 40)
turtle.circle(-80, 98)
turtle.setheading(-83)
# 叶子1
turtle.fd(30)
turtle.left(90)
turtle.fd(25)
turtle.left(45)
turtle.fillcolor("green")
turtle.begin_fill()
turtle.circle(-80, 90)
turtle.right(90)
turtle.circle(-80, 90)
turtle.end_fill()
turtle.right(135)
turtle.fd(60)
turtle.left(180)
turtle.fd(85)
turtle.left(90)
turtle.fd(80)
# 叶子2
turtle.right(90)
turtle.right(45)
turtle.fillcolor("green")
turtle.begin_fill()
turtle.circle(80, 90)
turtle.left(90)
turtle.circle(80, 90)
turtle.end_fill()
turtle.left(135)
turtle.fd(60)
turtle.left(180)
turtle.fd(60)
turtle.right(90)
turtle.circle(200, 60)
2.2 机器猫
import turtle
def flyTo(x, y):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
def drawEye():
turtle.tracer(False)
a = 2.5
for i in range(120):
if 0 <= i < 30 or 60 <= i < 90:
a -= 0.05
else:
a += 0.05
turtle.left(3)
turtle.fd(a)
turtle.tracer(True)
def beard():
""" 画胡子, 一共六根
"""
# 左边第一根胡子
flyTo(-37, 135)
turtle.seth(165)
turtle.fd(60)
# 左边第二根胡子
flyTo(-37, 125)
turtle.seth(180)
turtle.fd(60)
# 左边第三根胡子
flyTo(-37, 115)
turtle.seth(193)
turtle.fd(60)
# 右边第一根胡子
flyTo(37, 135)
turtle.seth(15)
turtle.fd(60)
# 右边第二根胡子
flyTo(37, 125)
turtle.seth(0)
turtle.fd(60)
# 右边第三根胡子
flyTo(37, 115)
turtle.seth(-13)
turtle.fd(60)
def drawRedScarf():
""" 画围巾
"""
turtle.fillcolor("red") # 填充颜色
turtle.begin_fill()
turtle.seth(0) # 朝向右
turtle.fd(200) # 前进10个单位
turtle.circle(-5, 90)
turtle.fd(10)
turtle.circle(-5, 90)
turtle.fd(207)
turtle.circle(-5, 90)
turtle.fd(10)
turtle.circle(-5, 90)
turtle.end_fill()
def drawMouse():
flyTo(5, 148)
turtle.seth(270)
turtle.fd(100)
turtle.seth(0)
turtle.circle(120, 50)
turtle.seth(230)
turtle.circle(-120, 100)
def drawRedNose():
flyTo(-10, 158)
turtle.fillcolor("red") # 填充颜色
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
def drawBlackdrawEye():
turtle.seth(0)
flyTo(-20, 195)
turtle.fillcolor("#000000") # 填充颜色
turtle.begin_fill()
turtle.circle(13)
turtle.end_fill()
turtle.pensize(6)
flyTo(20, 205)
turtle.seth(75)
turtle.circle(-10, 150)
turtle.pensize(3)
flyTo(-17, 200)
turtle.seth(0)
turtle.fillcolor("#ffffff")
turtle.begin_fill()
turtle.circle(5)
turtle.end_fill()
flyTo(0, 0)
def drawFace():
"""
"""
turtle.forward(183) # 前行183个单位
turtle.fillcolor("white") # 填充颜色为白色
turtle.begin_fill() # 开始填充
turtle.left(45) # 左转45度
turtle.circle(120, 100) # 右边那半边脸
turtle.seth(90) # 朝向向上
drawEye() # 画右眼睛
turtle.seth(180) # 朝向左
turtle.penup() # 抬笔
turtle.fd(60) # 前行60
turtle.pendown() # 落笔
turtle.seth(90) # 朝向上
drawEye() # 画左眼睛
turtle.penup() # 抬笔
turtle.seth(180) # 朝向左
turtle.fd(64) # 前进64
turtle.pendown() # 落笔
turtle.seth(215) # 修改朝向
turtle.circle(120, 100) # 左边那半边脸
turtle.end_fill() #
def drawHead():
""" 画了一个被切掉下半部分的圆
"""
turtle.penup() # 抬笔
turtle.circle(150, 40) # 画圆, 半径150,圆周角40
turtle.pendown() # 落笔
turtle.fillcolor("#00a0de") # 填充色
turtle.begin_fill() # 开始填充
turtle.circle(150, 280) # 画圆,半径150, 圆周角280
turtle.end_fill()
def drawAll():
drawHead()
drawRedScarf()
drawFace()
drawRedNose()
drawMouse()
beard()
flyTo(0, 0)
turtle.seth(0)
turtle.penup()
turtle.circle(150, 50)
turtle.pendown()
turtle.seth(30)
turtle.fd(40)
turtle.seth(70)
turtle.circle(-30, 270)
turtle.fillcolor("#00a0de")
turtle.begin_fill()
turtle.seth(230)
turtle.fd(80)
turtle.seth(90)
turtle.circle(1000, 1)
turtle.seth(-89)
turtle.circle(-1000, 10)
turtle.seth(180)
turtle.fd(70)
turtle.seth(90)
turtle.circle(30, 180)
turtle.seth(180)
turtle.fd(70)
turtle.seth(100)
turtle.circle(-1000, 9)
turtle.seth(-86)
turtle.circle(1000, 2)
turtle.seth(230)
turtle.fd(40)
turtle.circle(-30, 230)
turtle.seth(45)
turtle.fd(81)
turtle.seth(0)
turtle.fd(203)
turtle.circle(5, 90)
turtle.fd(10)
turtle.circle(5, 90)
turtle.fd(7)
turtle.seth(40)
turtle.circle(150, 10)
turtle.seth(30)
turtle.fd(40)
turtle.end_fill()
# 左手
turtle.seth(70)
turtle.fillcolor("#FFFFFF")
turtle.begin_fill()
turtle.circle(-30)
turtle.end_fill()
# 脚
flyTo(103.74, -182.59)
turtle.seth(0)
turtle.fillcolor("#FFFFFF")
turtle.begin_fill()
turtle.fd(15)
turtle.circle(-15, 180)
turtle.fd(90)
turtle.circle(-15, 180)
turtle.fd(10)
turtle.end_fill()
flyTo(-96.26, -182.59)
turtle.seth(180)
turtle.fillcolor("#FFFFFF")
turtle.begin_fill()
turtle.fd(15)
turtle.circle(15, 180)
turtle.fd(90)
turtle.circle(15, 180)
turtle.fd(10)
turtle.end_fill()
# 右手
flyTo(-133.97, -91.81)
turtle.seth(50)
turtle.fillcolor("#FFFFFF")
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
# 口袋
flyTo(-103.42, 15.09)
turtle.seth(0)
turtle.fd(38)
turtle.seth(230)
turtle.begin_fill()
turtle.circle(90, 260)
turtle.end_fill()
flyTo(5, -40)
turtle.seth(0)
turtle.fd(70)
turtle.seth(-90)
turtle.circle(-70, 180)
turtle.seth(0)
turtle.fd(70)
# 铃铛
flyTo(-103.42, 15.09)
turtle.fd(90)
turtle.seth(70)
turtle.fillcolor("#ffd200")
turtle.begin_fill()
turtle.circle(-20)
turtle.end_fill()
turtle.seth(170)
turtle.fillcolor("#ffd200")
turtle.begin_fill()
turtle.circle(-2, 180)
turtle.seth(10)
turtle.circle(-100, 22)
turtle.circle(-2, 180)
turtle.seth(180 - 10)
turtle.circle(100, 22)
turtle.end_fill()
flyTo(-13.42, 15.09)
turtle.seth(250)
turtle.circle(20, 110)
turtle.seth(90)
turtle.fd(15)
turtle.dot(10)
flyTo(0, -150)
drawBlackdrawEye()
def main():
turtle.screensize(800, 6000, "#F0F0F0")
turtle.pensize(3)
turtle.speed(9)
drawAll()
if __name__ == "__main__":
main()
turtle.mainloop()
2.3 小猪佩奇
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)
t.done()
2.4 樱花树
import turtle as T
import random
import time
# 画樱花的躯干(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()
2.5 小黄人
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()
2.6 皮卡丘
# 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()
2.7 多边形
#SquareSpiral1.py
import turtle as t
# t = turtle.Pen()
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("####结束####")
2.8 爱心
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()
-
python创意turtle作品和代码-python turtle示例源码(画出了漂亮的雪花)
2020-10-29 23:09:02【实例简介】漂亮雪花【实例截图】【核心代码】from turtle import *from random import *def ground():#画下面的土地hideturtle() #隐藏乌龟speed(100) #速度for i in range(400):pensize(randint(5,10))#画笔尺寸x...【实例简介】漂亮雪花
【实例截图】
【核心代码】
from turtle import *
from random import *
def ground():#画下面的土地
hideturtle() #隐藏乌龟
speed(100) #速度
for i in range(400):
pensize(randint(5,10))#画笔尺寸
x = randint(-400,350)#位置
y = randint(-280,-1)
r = -y/280
g = -y/280
b = -y/280
pencolor((r, g, b))#颜色暗色调, (1,1,1)白色;(0,0,0)黑色;(100)红色;(010)绿色;(001)蓝色
penup()
goto(x,y)#移动x轴
pendown()
forward(randint(40,100))
def snow():
hideturtle()
pensize(2)
speed(100)
for i in range(100):
r = random()
g = random()
b = random()
pencolor(r, g, b)#随机生成
penup()
setx(randint(-350,350))
sety(randint(1,270))
pendown()
dens = randint(8,12)#雪瓣
snowsize = randint(10,14)
for j in range(dens):
forward(snowsize)
backward(snowsize)
right(360/dens)
def main():
setup(800, 600, 0, 0)
tracer(False)
bgcolor("black")
snow()
ground()
tracer(True)
mainloop()
if __name__ == "__main__":
main()
-
python创意turtle作品和代码-Python使用turtle库绘制小猪佩奇(实例代码)
2020-10-29 22:55:16turtle(海龟)是Python重要的标准库之一,它能够进行基本的图形绘制。turtle图形绘制的概念诞生于1969年,成功应用于LOGO编程语言。turtle库绘制图形有一个基本框架:一个小海龟在坐标系中爬行,其爬行轨迹形成了...turtle(海龟)是Python重要的标准库之一,它能够进行基本的图形绘制。turtle图形绘制的概念诞生于1969年,成功应用于LOGO编程语言。
turtle库绘制图形有一个基本框架:一个小海龟在坐标系中爬行,其爬行轨迹形成了绘制图形。刚开始绘制时,小海龟位于画布正中央,此处坐标为(0,0),前进方向为水平右方。
在Python3系列版本安装目录的Lib文件夹下可以找到turtle.py文件。
下面通过代码给大家介绍Python使用turtle库绘制小猪佩奇,
具体代码如下所示:
# -*- coding:utf-8 -*-
import turtle as t
import time
def main():
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)
if __name__ == '__main__':
# 画小猪佩奇
main()
time.sleep(10)
执行结果:
总结
以上所述是小编给大家介绍的Python使用turtle库绘制小猪佩奇,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对我们网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!
本文标题: Python使用turtle库绘制小猪佩奇(实例代码)
本文地址: http://www.cppcns.com/jiaoben/python/298529.html
-
Python的turtle库还能绘制这些有趣图形?
2020-12-21 21:45:01在Python中,有一个内置的绘图模块,就是turtle。我们可以用它来绘制一些有趣的图形。 多边形 1、三边的效果: 2、六边的效果: 是不是觉得非常挺炫酷的,但其实实现它的代码非常简单,仅仅10行Python代码就能实现... -
python创意turtle作品-Python创意编程200例turtle篇
2020-10-30 23:10:45我们可以预见,全民会Python的日子不久就会到来,各行各业的人未来都能用Python解决各自领域的问题或创造出独特魅力的作品。在Python的普及过程中,海龟模块(turtle)将会功不可没。它来源于上个世纪60年代的logo... -
python创意turtle作品和代码-Python turtle.pen()用法及代码示例
2020-10-29 21:46:44turtle 模块以面向对象和面向过程的方式提供 turtle 图形基元。由于它使用Tkinter作为基础图形,因此需要安装有Tk支持的Python版本。turtle .pen()此功能用于通过以下键/值对在" pen-dictionary”中返回或设置... -
python创意turtle作品-Python turtle的多学科创意编程
2020-10-30 00:50:15原标题:Python turtle的多学科创意编程近日,以"智能时代,逐梦成长”为主题的第5届全国青少年创意编程与智能设计大赛正式开始,本届大赛增加了Python创意编程比赛。《中国科技教育》2019年第6期专题"... -
python创意turtle作品和代码-Python利用turtle库绘制彩虹代码示例
2020-10-29 20:52:00语言:PythonIDE:Python.IDE需求做出彩虹效果颜色空间RGB模型:光的三原色,共同决定色相HSB/HSV模型:H色彩,S深浅,B饱和度,H决定色相需要将HSB模型转换为RGB模型代码示例:#-*- coding:utf-8 –*-from turtle ... -
Python创意编程视频课CSDN版
2020-03-18 16:19:44无需编程基础! 适合广大民众,无论是少儿还是成人学习的Python趣味编程课程。 这是李兴球制作的Python趣味编程教学视频, 学习后可以轻松地学到Python知识,非常轻松地用Python创建游戏与动画。... -
python创意turtle作品-使用 Python Turtle 设计简单而又美丽的图形
2020-10-30 00:06:09使用 Python Turtle 设计简单而又美丽的图形看看本文中这些美丽的图画。正是这样的事情让我爱上了 turtle。优秀的程序员会认为turtle是"落后原始的”,但我不敢苟同。在本教程中,我将用Python为turtle编写一个... -
【Python Turtle合集】有趣好玩的代码当然要分享给大家啦~(皮卡丘、玫瑰花、小黄人......)
2022-03-24 20:11:29**文章简介 **:本篇文章主要是写了利用Turtle库绘制四种不一样的图案的小程序! **文章源码免费获取 : 为了感谢每一个关注我的小可爱每篇文章的项目源码都是无 偿分享滴 点这里蓝色这行字体自取,需要什么... -
python创意小作品-python turtle库的几个小demo
2020-10-28 21:47:23一、先上图一个同切圆和五角星上代码import turtle#同切圆turtle.pensize(2)turtle.circle(10)turtle.circle(40)turtle.circle(80)turtle.circle(160)#五角星from turtle import *color('red','yellow')begin_fill()... -
轻松学会python的turtle模块,画一箭穿心、小人儿发射爱心、520表白完整代码,海龟作图小创意
2020-10-28 14:41:04当我们学了turtle后(如果不懂turtle模块的话,文章末尾会详细介绍的),就想尝试为自己心里喜欢的人画一颗一颗爱心,想用代码逗自己的小猪猪女孩开心,表达自己的爱意,那么福利来了,动动小手指,复制粘贴即可,... -
python创意turtle作品-python turtle库的几个小demo
2020-10-29 23:50:29一、先上图一个同切圆和五角星上代码import turtle#同切圆turtle.pensize(2)turtle.circle(10)turtle.circle(40)turtle.circle(80)turtle.circle(160)#五角星from turtle import *color('red','yellow')begin_fill()... -
python创意小作品-[专题]在Python教学中应用turtle创意编程实践
2020-10-28 22:10:59原标题:[专题]在Python教学中应用turtle创意编程实践创意编程是用编程实现自己创意的过程。在2017年的信息技术新课程标准中,计算思维是信息技术的核心素养。计算思维是指利用计算机科学领域的思想方法,在形成问题... -
python创意turtle作品-大部分人都不知道-Python竟能画这么漂亮的花,帅呆了
2020-10-30 00:39:54画一个海龟走两步的图 我们让海龟在图上走100步,然后再往下45度走100步 import turtle def draw_art(): window=turtle.Screen() window.bgcolor("blue") brad=turtle.Turtle()#创建一个Turtle的实例 brad.shape(... -
python创意turtle作品-[专题]在Python教学中应用turtle创意编程实践
2020-10-30 00:48:15原标题:[专题]在Python教学中应用turtle创意编程实践创意编程是用编程实现自己创意的过程。在2017年的信息技术新课程标准中,计算思维是信息技术的核心素养。计算思维是指利用计算机科学领域的思想方法,在形成问题... -
在Python教学中应用turtle创意编程实践
2020-11-30 01:38:28毛华均创意编程是用编程实现自己创意的过程。在2017年的信息技术新课程标准中,计算思维是信息技术的核心素养。计算思维是指利用計算机科学领域的思想方法,在形成问题解决方案的过程中产生的一系列思维活动。在创意... -
python的turtle库画出创意图
2020-02-12 14:28:46最近空余时间在了解一下火热的python,今天看到了利用turtle画图的这一章节,虽然不知道将来有什么应用场景,不过这么简单这么强大,还是点一个赞。 没啥好介绍的,直接上代码,上结果 1、代码很简单,画一个漂亮的... -
python创意小作品-Python竟能画这么漂亮的花,帅呆了(代码分享)
2020-10-29 14:27:22画一个海龟走两步的图 我们让海龟在图上走100步,然后再往下45度走100步 import turtle def draw_art(): window=turtle.Screen() window.bgcolor("blue") brad=turtle.Turtle()#创建一个Turtle的实例 brad.shape(... -
python精彩编程200例-Python创意编程200例turtle篇
2020-10-28 22:37:28我们可以预见,全民会Python的日子不久就会到来,各行各业的人未来都能用Python解决各自领域的问题或创造出独特魅力的作品。在Python的普及过程中,海龟模块(turtle)将会功不可没。它来源于上个世纪60年代的logo... -
python创意爱情代码-python turtle库的几个小demo
2020-10-30 00:00:52一、先上图一个同切圆和五角星上代码import turtle#同切圆turtle.pensize(2)turtle.circle(10)turtle.circle(40)turtle.circle(80)turtle.circle(160)#五角星from turtle import *color('red','yellow')begin_fill()... -
Python Turtle:小海龟创意绘画,仰望星空,脚踏实地,配有背景音乐哦!(附源码,可以学习如何添加背景音乐...
2021-10-01 17:24:21def play_music(): file=r'little_star_music.mp3' #最好把背景音乐文件和代码文件放在一个文件夹下,这里填背景音乐文件路径 pygame.mixer.init() track=pygame.mixer.music.load(file) pygame.mixer.music.play... -
python精彩编程200例 pdf-Python创意编程200例turtle篇
2020-10-30 23:09:59我们可以预见,全民会Python的日子不久就会到来,各行各业的人未来都能用Python解决各自领域的问题或创造出独特魅力的作品。在Python的普及过程中,海龟模块(turtle)将会功不可没。它来源于上个世纪60年代的logo... -
Python之turtle库画各种有趣的图及源码(更新中)
2021-02-08 18:19:12Turtle库是Python语言中一个很流行的绘制图像的函数库,想象一个小乌龟,在一个横轴为x、纵轴为y的坐标系原点,(0,0)位置开始,它根据一组函数指令的控制,在这个平面坐标系中移动,从而在它爬行的路径上绘制了图形... -
Python创意编程100例turtle篇题目串烧
2019-10-16 08:10:09《Python创意编程100例turtle篇》是李兴球原创的用turtle模块编制作精选作品集合。在这个集合里包括了历史、天文、国学、游戏、音乐艺术、课件、数学几何、编程技巧、绘画艺术甚至相声与诗词等。上面是由部分题目所... -
用python中的turtle库绘制一些有趣的图
2021-11-20 14:51:56具体代码如下: #画蚊香 import turtle turtle.pensize(30) for i in range(30): turtle.circle(i*10,60) turtle.done() 2 图2 第二个图是蚊香的变体图,怎么通过调整蚊香代码,更改颜色...