forked from Rishi098/Python_Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChess_Board.py
66 lines (44 loc) · 903 Bytes
/
Chess_Board.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# import turtle package
import turtle
# create screen object
sc = turtle.Screen()
# create turtle object
pen = turtle.Turtle()
# method to draw square
def draw():
for i in range(4):
pen.forward(30)
pen.left(90)
pen.forward(30)
# Driver Code
if __name__ == "__main__" :
# set screen
sc.setup(600, 600)
# set turtle object speed
pen.speed(100)
# loops for board
for i in range(8):
# not ready to draw
pen.up()
# set position for every row
pen.setpos(0, 30 * i)
# ready to draw
pen.down()
# row
for j in range(8):
# conditions for alternative color
if (i + j)% 2 == 0:
col ='black'
else:
col ='white'
# fill with given color
pen.fillcolor(col)
# start filling with colour
pen.begin_fill()
# call method
draw()
# stop filling
pen.end_fill()
# hide the turtle
pen.hideturtle()
# This code is contributed by Deepanshu Rustagi.