Dynamic Sized Chessboard in Python using Turtle Module.
from turtle import *
#Function to draw the box of given size and color
def box(size,color):
pd()
fillcolor(color)
begin_fill()
for i in range(4):
fd(size)
rt(90)
end_fill()
speed(10)
pu()
size=50
x=-size*4
y=size*4
goto(x,y)
pd()
bx=1
for row in range(8):
for col in range(8):
if (bx+row)%2 == 0:
box(size,'blue')
else:
box(size,'yellow')
bx+=1
x=x+size
goto(x,y)
y=y-size
x=-size*4
pu()
goto(x,y)
pd()
mainloop()
No comments
Post your comments