<> Peppa Pig
# coding:utf-8 import turtle as t t.pensize(4) # Sets the size of the brush t.colormode(255) #
set up GBK The color range is 0-255 t.color((255,155,192),"pink") # Set the brush color and fill color (pink) t.setup(840,
500) # Set the size of the main window to 840*500 t.speed(10) # Set the brush speed to 10 # nose t.pu() # write t.goto(-100,100)
# Brush to coordinates (-100,100) t.pd() # Writing t.seth(-30) # The angle of the pen is -30° t.begin_fill() #
Start mark of shape filling a=0.4 for i in range(120): if 0<=i<30 or 60<=i<90: a=a+0.08 t.lt(3)
# turn left 3 degree t.fd(a) # Move on a Step size of else: a=a-0.08 t.lt(3) t.fd(a) t.end_fill() # Fill by contour t.
pu() # write t.seth(90) # The angle of the pen is 90 degree t.fd(25) # Move forward 25 t.seth(0) # Change the angle of the brush to 0 t.fd(10)
t.pd() t.pencolor(255,155,192) # Set brush color t.seth(10) t.begin_fill() t.circle(5)
# Draw a radius of 5 The circle of t.color(160,82,45) # Set brush and fill colors 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() # head 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) #
Draw a radius clockwise 300, The center angle of the circle is 30° My garden 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)
# turn left 3 degree t.fd(a) # Move on a Step size of else: a=a-0.08 t.lt(3) t.fd(a) t.end_fill() # Ears 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() # eye
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() # Gill 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() # mouth 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)
# body 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() # hand 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) # foot 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) # tail 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)
result :
<> Come more a dream
# * -- utf-8 -- * # Author: Tang import turtle as t t.speed(10) t.pensize(8) t.
hideturtle() t.screensize(500, 500, bg='white') # Cat face 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) # turn left 3 degree t.fd(a) # Move on a Step size of 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) # turn left 3 degree t.fd(a) # Move on a Step size of 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) # The beard on the left 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() # necktie 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) # small bell 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()
result :
<> Pikachu
#!/usr/bin/env python # -*- coding:utf-8 -*- from turtle import * ''' Drawing the head of Pikachu
''' def face(x,y): """ Face painting """ begin_fill() penup() # Move the turtle to the specified coordinates goto(x, y)
pendown() # Set the direction of the turtle setheading(40) circle(-150, 69) fillcolor("#FBD624") #
Move the turtle to the specified coordinates penup() goto(53.14, 113.29) pendown() setheading(300) circle(-150,
30) setheading(295) circle(-140, 20) print(position()) forward(5) setheading(260
) circle(-80, 70) print(position()) penup() goto(-74.43,-79.09) pendown() penup(
) # Move the turtle to the specified coordinates goto(-144,103) pendown() setheading(242) circle(110, 35) right(
10) forward(10) setheading(250) circle(80, 115) print(position()) penup() goto(-
74.43,-79.09) pendown() setheading(10) penup() goto(-144, 103) pendown() penup()
goto(x, y) pendown() end_fill() # chin penup() goto(-50, -82.09) pendown()
pencolor("#DDA120") fillcolor("#DDA120") begin_fill() setheading(-12) circle(120
, 25) setheading(-145) forward(30) setheading(180) circle(-20, 20) setheading(
143) forward(30) end_fill() # penup() # # Move the turtle to the specified coordinates # goto(0, 0) # pendown()
def eye(): """ Draw eyes """ # left eye color("black","black") penup() goto(-110, 27) pendown(
) begin_fill() setheading(0) circle(24) end_fill() # Left eye color("white", "white")
penup() goto(-105, 51) pendown() begin_fill() setheading(0) circle(10) end_fill
() # right eye color("black", "black") penup() goto(25, 40) pendown() begin_fill()
setheading(0) circle(24) end_fill() # Right eye color("white", "white") penup() goto(
17, 62) pendown() begin_fill() setheading(0) circle(10) end_fill() def cheek():
""" Draw cheek """ # right color("#9E4406", "#FE2C21") penup() goto(-130, -50) pendown()
begin_fill() setheading(0) circle(27) end_fill() # left color("#9E4406", "#FE2C21"
) penup() goto(53, -20) pendown() begin_fill() setheading(0) circle(27) end_fill
() def nose(): """ Draw nose """ color("black", "black") penup() goto(-40, 38) pendown()
begin_fill() circle(7,steps = 3) end_fill() def mouth(): """ Draw mouth """ color("black"
, "#F35590") # Lips penup() goto(-10, 22) pendown() begin_fill() setheading(260)
forward(60) circle(-11, 150) forward(55) print(position()) penup() goto(-38.46,
21.97) pendown() end_fill() # tongue color("#6A070D", "#6A070D") begin_fill() penup(
) goto(-10.00, 22.00) pendown() penup() goto(-14.29, -1.7) pendown() penup()
goto(-52, -5) pendown() penup() goto(-60.40, 12.74) pendown() penup() goto(-
38.46, 21.97) pendown() penup() goto(-10.00, 22.00) pendown() end_fill() color(
"black","#FFD624") penup() goto(-78, 15) pendown() begin_fill() setheading(-25)
for i in range(2): setheading(-25) circle(35, 70) end_fill() color("#AB1945",
"#AB1945") penup() goto(-52, -5) pendown() begin_fill() setheading(40) circle(-
33, 70) goto(-16,-1.7) penup() goto(-18,-17) pendown() setheading(155) circle(25
, 70) end_fill() def ear(): """ Draw ears """ # Left ear color("black","#FFD624") penup() goto
(-145, 93) pendown() begin_fill() setheading(165) circle(-248,50) right(120)
circle(-248,50) end_fill() color("black", "black") penup() goto(-240, 143)
pendown() begin_fill() setheading(107) circle(-170, 25) left(80) circle(229, 15)
left(120) circle(300, 15) end_fill() # Right ear color("black", "#FFD624") penup()
goto(30, 136) pendown() begin_fill() setheading(64) circle(-248, 50) right(120)
circle(-248, 50) end_fill() color("black", "black") penup() goto(160, 200)
pendown() begin_fill() setheading(52) circle(170, 25) left(116) circle(229, 15)
left(71) circle(-300, 15) end_fill() def setting(): """ Setting parameters """ pensize(2) # Hidden turtle
hideturtle() speed(10) def main(): """ Principal function """ setting() face(-132,115) eye()
cheek() nose() mouth() ear() done() if __name__ == '__main__': main()
result :
<> Little Turtle
import turtleturtle.setup(1000,800)turtle.speed(6)turtle.colormode(255)turtle.
color((0,0,0),(60,100,30))turtle.penup()turtle.goto(0,-200)turtle.pendown()
turtle.begin_fill()turtle.circle(200)turtle.end_fill()turtle.pensize(2)turtle.
penup()turtle.goto(190,-60)turtle.pendown()turtle.goto(-190,-60)turtle.penup()
turtle.goto(190,60)turtle.pendown()turtle.goto(-190,60)turtle.penup()turtle.goto
(60,190)turtle.pendown()turtle.goto(60,-190)turtle.penup()turtle.goto(-60,190)
turtle.pendown()turtle.goto(-60,-190)turtle.penup()turtle.pensize(1)turtle.goto(
20,198)turtle.penup()turtle.goto(0,200)turtle.pendown()turtle.color((0,0,0),(60,
80,30))turtle.begin_fill()a=1turtle.speed(0)for i in range(120): if 0<=i<30 or
60<=i<=90: a=a+0.04 turtle.lt(3) turtle.fd(a) else: a=a-0.04 turtle.lt(3) turtle
.fd(a)turtle.penup()turtle.end_fill() turtle.color((0,0,0),(255,255,255))turtle.
goto(11,240)turtle.begin_fill()turtle.pendown()turtle.circle(5)turtle.end_fill()
turtle.penup()turtle.end_fill()turtle.color((0,0,0),(255,255,255))turtle.goto(-
11,240)turtle.begin_fill()turtle.pendown()turtle.circle(5)turtle.end_fill()
turtle.penup() turtle.color((0,0,0),(0,0,0))turtle.goto(10,240)turtle.begin_fill
()turtle.pendown()turtle.circle(3)turtle.end_fill()turtle.penup()turtle.end_fill
()turtle.color((0,0,0),(0,0,0))turtle.goto(-10,240)turtle.begin_fill()turtle.
pendown()turtle.circle(3)turtle.end_fill()turtle.penup()turtle.color((0,0,0),(60
,80,30))turtle.goto(-120,150)turtle.pendown()turtle.seth(30)turtle.begin_fill()a
=0.3for i in range(120): if 0<=i<30 or 60<=i<=90: a=a+0.06 turtle.lt(3) turtle.
fd(a) else: a=a-0.06 turtle.lt(3) turtle.fd(a)turtle.end_fill()turtle.penup()
turtle.goto(120,150)turtle.pendown()turtle.seth(-30)a=0.3turtle.begin_fill()for
iin range(120): if 0<=i<30 or 60<=i<=90: a=a+0.06 turtle.lt(3) turtle.fd(a) else
: a=a-0.06 turtle.lt(3) turtle.fd(a)turtle.penup()turtle.end_fill()turtle.goto(-
120,-160)turtle.pendown()turtle.seth(-210)turtle.begin_fill()a=0.5for i in range
(120): if 0<=i<30 or 60<=i<=90: a=a+0.03 turtle.lt(3) turtle.fd(a) else: a=a-
0.03 turtle.lt(3) turtle.fd(a) turtle.penup()turtle.end_fill()turtle.goto(120,-
160)turtle.pendown()turtle.seth(210)turtle.begin_fill()a=0.5for i in range(120):
if 0<=i<30 or 60<=i<=90: a=a+0.03 turtle.lt(3) turtle.fd(a) else: a=a-0.03
turtle.lt(3) turtle.fd(a)turtle.end_fill()turtle.penup()turtle.goto(0,-200)
turtle.seth(0)turtle.pendown() turtle.begin_fill()turtle.fd(10)turtle.seth(-105)
turtle.fd(30)turtle.seth(105)turtle.fd(30)turtle.seth(0)turtle.fd(10)turtle.
end_fill()turtle.hideturtle()turtle.mainloop()
result :
<> Pentagonal ring
import turtle as t t.goto(100,0) for i in range(50): t.left(80) t.fd(100) t.
left(135) t.fd(105)
result :
<> Big windmill
import turtle as t t.goto(100,0) for i in range(100): t.left(80) t.fd(100) t.
left(135) t.fd(165) t.left(125) t.fd(115)
result :
What's wrong? I hope you can include it , I also want to point out mistakes in the comments section , Xiaobian will correct the mistakes in time and learn from them , At the same time, I hope you can share some interesting programs , Bring happiness to more people .
Technology
Daily Recommendation