赞
踩
本文实例为大家分享了python图形工具turtle绘制国际象棋棋盘的具体代码,供大家参考,具体内容如下
#编写程序绘制一个国际象棋的棋盘
import turtle
turtle.speed(30)
turtle.penup()
off = true
for y in range(-40, 30 + 1, 10):
for x in range(-40, 30 + 1, 10):
if off:
turtle.goto(x, y)
turtle.pendown()
turtle.begin_fill()
turtle.color("black")
turtle.forward(10)
turtle.left(90)
turtle.forward(10)
turtle.left(90)
turtle.forward(10)
turtle.left(90)
turtle.forward(10)
turtle.left(90)
turtle.end_fill()
turtle.penup()
else:
turtle.goto(x, y)
turtle.pendown()
turtle.forward(10)
turtle.left(90)
turtle.forward(10)
turtle.left(90)
turtle.forward(10)
turtle.left(90)
turtle.forward(10)
turtle.left(90)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。