python3 turtle 画围棋棋盘
python3 环境
利用turtle模块画出 围棋棋盘
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:Hiuhung Wan import turtle
n = 30 #两条线间隔
x = -300 # x初始值
y = -300 # y初始值 turtle.speed(9) turtle.screensize(400, 400)
turtle.penup()
turtle.pencolor('black') for i in range(19):
turtle.goto(x, y + n * i)
turtle.pendown()
turtle.forward(18 * n) #下面一条横线
turtle.penup()
# 19条横线已画完 turtle.left(90)
for i in range(19):
turtle.goto(x + n * i, y)
turtle.pendown()
turtle.forward(18 * n)
turtle.penup()
# 19条坚线已画完 turtle.right(90)
turtle.hideturtle() # 画9个大圆点
x0 = x + 3 * n
y0 = y + 3 * n - n * 0.25
for i in range(3):
for j in range(3):
turtle.goto(x0 + i * 6 * n, y0 + j * 6 * n)
#turtle.pencolor('black')
turtle.begin_fill()
turtle.fillcolor('black')
turtle.circle(n * 0.25)
turtle.end_fill() turtle.done()
效果图:

python3 turtle 画围棋棋盘的更多相关文章
- python3 turtle 画国际象棋棋盘
python3 turtle 画国际象棋棋盘 #!/usr/bin/env python # -*- coding:utf-8 -*- # Author:Hiuhung Wan import turt ...
- Python语言程序设计之二--用turtle库画围棋棋盘和正、余弦函数图形
这篇笔记依然是在做<Python语言程序设计>第5章循环的习题.其中有两类问题需要记录下来. 第一是如何画围棋棋盘.围棋棋盘共有19纵19横.其中,位于(0,0)的星位叫天元,其余8个星位 ...
- python3 turtle画正方形、矩形、正方体、五角星、奥运五环
python3 环境 turtle模块 分别画出 正方形.矩形.正方体.五角星.奥运五环 #!/usr/bin/env python # -*- coding:utf-8 -*- # Author:H ...
- Python3 turtle安装和使用教程
Python3 turtle安装和使用教程 Turtle库是Python语言中一个很流行的绘制图像的函数库,想象一个小乌龟,在一个横轴为x.纵轴为y的坐标系原点,(0,0)位置开始,它根据一组函数 ...
- python运用turtle 画出汉诺塔搬运过程
python运用turtle 画出汉诺塔搬运过程 1.打开 IDLE 点击File-New File 新建立一个py文件 2.向py文件中输入如下代码 import turtle class Stac ...
- day 03 turtle 画鹅
turtle 画鹅 import turtle t=turtle turtle.speed(10) t. setup(800,600) #画头 turtle.penup() turtle.goto(0 ...
- *【Python】【demo实验31】【练习实例】【使用turtle画小猪佩奇】
如下图小猪佩奇: 要求使用turtle画小猪佩奇: 源码: # encoding=utf-8 # -*- coding: UTF-8 -*- # 使用turtle画小猪佩奇 from turtle i ...
- 【Python】【demo实验29】【练习实例】【使用turtle画五角星】
原题: 使用turtle画五角星: 我的代码: #!/usr/bin/python # encoding=utf-8 # -*- coding: UTF-8 -*- from turtle impor ...
- Python之turtle画同心圆和棋盘
画饼图 import turtle t = turtle.Pen() for i in range(5): t.penup() t.goto(0, -i*30) t.pendown() t.circl ...
随机推荐
- cogs 32. [POI1999] 位图
32. [POI1999] 位图 ★ 输入文件:bit.in 输出文件:bit.out 简单对比时间限制:1 s 内存限制:128 MB [问题描述 ] 给定一个 n*m 的矩形位图, ...
- HDU4596 Yet another end of the world 扩展欧几里德性质
这题坑了,我真该吃翔啊,竟然一開始方程设错了并且没有去想连列的问题,我真是坑货,做不出就该又一次理一下嘛.操蛋. 题意:给了N组x,y,z然后 问你是否存在两个或者两个以上的id,是的 id%x的值在 ...
- 7.Web Service 调用天气代码
1. 2500多个城市天气预报 WEB服务公用事业 Endpoint:http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx Disco: ...
- POJ 3040 贪心
贪心好题 ---. 思路: 从大到小凑C 如果不够 再从小到大补满(超过)C //By SiriusRen #include <cstdio> #include <cstring&g ...
- OpenCV —— 视频播放控制
创建滚动条,实现滚动条随视频播放移动. #include "cv.h" #include "highgui.h" CvCapture* capture=NULL ...
- HDP和HDF
参考文档: HDP安装: 官方文档:https://docs.hortonworks.com/HDPDocuments/Ambari-2.5.0.3/bk_ambari-installation/co ...
- Oracle442个应用场景-----------Oracle数据库物理结构
-------------------------Oracle数据库物理结构------------------------------- Oracle数据库物理结构 oracle的数据,实际 ...
- js13--对象、原型
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...
- eclipse个人插件
1.SVN eclipse markets 安装m2e-subversion.svnkit 2.maven 本地装好mvn prefences导入maven安装目录和配置 3.单元测试覆盖率 EclE ...
- tooltip两个特殊的属性
<body style="margin: 50px;"> <!--两个特殊的属性--> <div id="selection"&g ...