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 ...
随机推荐
- Expression表达式树(C#)
Lambda表达式: 1.下面举例通过Lambda表达式创建了一个用于验证Name的Func委托. //通过Lambda表达式创建一个对象的Name属性验证委托 Func<SearchInfo, ...
- linux ifconfig找不到
提示命令不存在 原因: 系统默认的环境变量设置不对 而,ifconfig恰恰就在/sbin里面. 下cat /etc/profile, 可以发现没有关于/sbin的环境变量. Linux,习惯用ged ...
- 洛谷 P2080 增进感情
P2080 增进感情 题目背景 小明和小红的感情,是慢慢发展起来的. 题目描述 他们对对方分别有一个好感值.定义两人的亲密程度为两人的好感值之和. 如果他们的亲密程度达到V,则他们将走到一起.他们以后 ...
- 从2014年D2前端技术论坛看前端发展趋势
上周六有幸參加了在杭州阿里巴巴西溪园区举办的2014年D2前端技术论坛和晚上的酒会.实地感受了一下阿里巴巴前端开发的技术氛围和影响力.整体上看这次D2规模还是挺大的,国内前端的知名大牛基本上都到了. ...
- openstack-dashboard开发环境搭建
1,在开发过程中,一般都要,将dashboard这个组件单独执行在自己的本地的linux系统中(Ubuntu或centos),那个比較顺手用哪个.假设不习惯,能够用vmwareworkstation安 ...
- Redisclient连接方式Hiredis简单封装使用,连接池、屏蔽连接细节
工作须要对Hiredis进行了简单封装,实现功能: 1.API进行统一,对外仅仅提供一个接口. 2.屏蔽上层应用对连接的细节处理: 3.底层採用队列的方式保持连接池,保存连接会话. 4.重连时採用时间 ...
- DistBelief 框架下的并行随机梯度下降法 - Downpour SGD
本文是读完 Jeffrey Dean, Greg S. Corrado 等人的文章 Large Scale Distributed Deep Networks (2012) 后的一则读书笔记,重点 ...
- android framework 02
Android底层开发1.安装Ubuntu系统2.Ubuntu配置开发环境: sudo apt-get install git-core gnupg flex bison gperf zip sudo ...
- 3.常用Bracket插件
转自:https://blog.csdn.net/iso_wsy/article/details/52608205 1.Emmet 如果你从事Web前端开发的话,对该插件一定不会陌生.它可以加快你的 ...
- 洛谷P1720 月落乌啼算钱
目背景 (本道题目木有以藏歌曲……不用猜了……) <爱与愁的故事第一弹·heartache>最终章. 吃完pizza,月落乌啼知道超出自己的预算了.为了不在爱与愁大神面前献丑,只好还是硬着 ...