Home > other >  Python with turtle how to draw the graphics
Python with turtle how to draw the graphics

Time:11-29

Using def function and the method of the for loop, everyone a great god help

CodePudding user response:

 import turtle 

Def the draw [color='green', startX=0, startY=100, L=100) :
Tu=turtle. The turtle ()

Tu. Hideturtle ()
Tu. Pensize (4)
Tu. Penup ()
Tu. Goto (x=startX, y=startY)

Tu. Pd ()
Tu. Begin_fill ()
For _ in range (3) :
Tu. Fd (L)
Tu. Left (120)
Tu. Fillcolor (color)

Tu. End_fill ()

If __name__=="__main__" :
Color=[' green ', 'red' and 'blue']
X1, y1, L=0, 100, 100

For _ in color:
The draw (_, x1, y1, L)
X1=x1 + L//2

Turtle. Mainloop ()
 

CodePudding user response:

The program can run normally
  • Related