Turtle the code used to draw the simple drawing:
1Turtle.showturtle ()#Drawing Board2Turtle.screensize (2024,2000)#drawing board Size3Turtle.forward ()#move forward4Turtle.right (90)#direction left to adjust N degrees5Turtle.left (30)#direction to right adjust n degrees6Turtle.write ("Hello")#Write Text7Turtle.goto (50,50)#Coordinate movement8Turtle.penup ()#Lifting Pen9Turtle.pendown ()# pen DownTen OneTurtle.circle (100)#Draw a circle ATurtle.done ()#Show does not exit -Turtle.reset ()# Reset -Turtle.begin_fill ()#Start filling theTurtle.circle (100,steps=5)#set the Edge shape -Turtle.color ("Red")#Brush color Default Black -Turtle.end_fill ()#End Fill -Turtle.hideturtle ()#Hide Arrows +Turtle.pensize (" the")#Brush Size -Turtle.write ("Hello World", Font= ("Chinese Amber", 20,"Normal"))#Set Font +Turtle.screensize (2024,2718)#Artboard Size ATurtle.dot (10,"Black")#Fill Circle
Draw a Go board below
1 Turtle.showturtle ()2Turtle.screensize (2000,2000)3M=204 forIinchRange (19):5 Turtle.penup ()6Turtle.goto (0,20*i)7 Turtle.pendown ()8Turtle.forward (20*18)9Turtle.right (270)Ten forIinchRange (19): One Turtle.penup () ATurtle.goto (20*i,0) - Turtle.pendown () -Turtle.forward (20*18) theTurtle.dot (10,"Black") -Turtle.done ()
View Code
Chess
1 Turtle.showturtle ()2M=203 4 forIinchRange (8):#Draw multiple Square positions5 forJinchRange (8):6 Turtle.penup ()7Turtle.goto (i*m,j*m)8 Turtle.pendown ()9 Turtle.begin_fill ()Ten #draw a square . One forKinchRange (4): A Turtle.forward (m) -Turtle.right (90) - #Judging black and white, i+j even black, odd white the if(I+J)%2==0: -Turtle.color ("Black") - Else: -Turtle.color (" White") + - Turtle.end_fill () + ATurtle.done ()
View Code
Line chart
1 ImportTurtle2 forIinchRange (0,300,100):3 forJinchRange (0,400,100):4 Turtle.goto (j,i)5 Turtle.pendown ()6Turtle.write (str (i) +","+Str (j))7 Turtle.penup ()8 9Turtle.done ()
View Code
Finally, draw a cube.
1 ImportTurtle2 3Turtle.goto (200, 0)4Turtle.goto (200,200)5Turtle.goto (0,200)6 Turtle.goto (0,0)7 8 Turtle.penup ()9Turtle.goto (100,100)Ten Turtle.pendown () One A Turtle.begin_fill () -Turtle.goto (100,-100) -Turtle.goto ( -100,-100) theTurtle.goto (-100,100) -Turtle.goto (100,100) -Turtle.color ("Red") - Turtle.end_fill () + -Turtle.goto (200,200) + Turtle.penup () ATurtle.goto (100,-100) at Turtle.pendown () -Turtle.goto (200, 0) - Turtle.penup () -Turtle.goto ( -100,-100) - Turtle.pendown () - Turtle.goto (0,0) in Turtle.penup () -Turtle.goto (-100,100) to Turtle.pendown () +Turtle.goto (0,200) -Turtle.color ("Blue") theTurtle.write ("Hello Python", Font= ("italics"," -","Normal")) *Turtle.done ()
View Code
Python_turtle Template Drawing