The practice of Python learning
A chess board drawn with turtle
Import Turtleturtle.speed a = 30# painting background turtle.up () Turtle.goto ( -10, -10) Turtle.down () Turtle.fillcolor ("Khaki") Turtle.begin_fill () TURTLE.FD (A * 8 +) Turtle.left (+) TURTLE.FD (A * 8 +) Turtle.left (A * 8 +) turtle.fd. Left (TURTLE.FD) (A * 8 +) Turtle.left (All) Turtle.end_fill () #画黑格for I in range (8): If I% 2 = = 0: #偶数行 turtle.u P () Turtle.goto (0, I * a) Turtle.down () for J in Range (4): Turtle.fillcolor ("Black") Turtle.begin_fill () turtle.fd (a) turtle.left (a) turtle.fd (a) turtle . Left (TURTLE.FD) (a) turtle.left (a) turtle.fd (a) turtle.left (90) Turtle.end_fill () turtle.up () TURTLE.FD (A * 2) Turtle.down () Else: #奇数行 Tur Tle.up () Turtle.goto (A, A * i) Turtle.down () for N in range (4): Turtle.fillcolor ("Black ") Turtle.begin_fill () TURTLE.FD (a) turtle.left (a) turtle.fd (a) turtle.left (+) turtle. FD (a) turtle.left (a) turtle.fd (a) turtle.left (+) Turtle.end_fill () Turtle.up () TURTLE.FD (A * 2) Turtle.down () #画白格turtle. Up () Turtle.goto (0, 0) turtle.down () Tur TLE.FD (A * 8) turtle.left (All) turtle.fd (A * 8) turtle.left (All) turtle.fd (A * 8) turtle.left (+) TURTLE.FD (A * 8) TURTLE.L EFT (+) Turtle.done ()
Results
Python draws chess board with turtle