Skip to content

Instantly share code, notes, and snippets.

@juanfal
Last active March 14, 2023 12:03
Show Gist options
  • Save juanfal/0bfa3ca9ef46b85cdba9585395d271ff to your computer and use it in GitHub Desktop.
Save juanfal/0bfa3ca9ef46b85cdba9585395d271ff to your computer and use it in GitHub Desktop.
Drawing a chessboard with python turtle
# chessboard.py
# juanfc 2023-03-14
#
from turtle import *
ancho = 50
speed(0)
color("black", "black")
penup()
goto(-4*ancho, -4*ancho)
for fila in range(8):
for i in range(4):
pendown()
begin_fill()
for i in range(4):
fd(ancho)
left(90)
end_fill()
penup()
setx(xcor()+ancho*2)
if fila % 2 == 0:
setx(-4*ancho+ancho)
else:
setx(-4*ancho)
sety(ycor()+ancho)
penup()
goto(-4*ancho, -4*ancho)
setheading(0)
pendown()
for i in range(4):
fd(ancho*8)
left(90)
done()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment