本文实例为大家分享了python使用turtle画国际象棋棋盘的具体代码,供大家参考,具体内容如下
使用的方法是每一个小格每一个小格的画
import turtle
for i in range(8): #一共有八列
for j in range(8):#每一行有八个格
turtle.forward(37.5)
if j % 2 == 0:#判断是否为第奇数个格(是否画黑色格)
if i % 2 ==0:#判断是否为奇数行(调整画黑色正方形时小海龟的转向)
turtle
本文实例为大家分享了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.b
本文实例为大家分享了shell打印国际象棋棋盘的具体代码,供大家参考,具体内容如下
代码如下:
#!/bin/bash
#set chess cell's width
read -p Please set the chess cell's width( two space width as unit ): width
if [[ $width =~ ^[0-9]+$ ]];then
echo wrong width setting, check your input and try agai