码迷,mamicode.com
首页 > 编程语言 > 详细

Python之turtle画同心圆和棋盘

时间:2018-11-04 12:38:55      阅读:993      评论:0      收藏:0      [点我收藏+]

标签:hal   image   tle   棋盘   info   speed   got   pytho   span   

画饼图

import turtle

t = turtle.Pen()

for i in range(5):
    t.penup()
    t.goto(0, -i*30)
    t.pendown()
    t.circle(i*30+30)

turtle.done()

技术分享图片

 

画棋盘

import turtle

t = turtle.Pen()

widthall = 200
width = 20
num = widthall // 20 * 2 + 1

t.speed(10)

for r in range(num):
    t.penup()
    t.goto(-widthall, widthall - width * r)
    t.pendown()
    t.goto(widthall, widthall - width * r)

for c in range(num):
    t.penup()
    t.goto(-widthall + width * c, widthall)
    t.pendown()
    t.goto(-widthall + width * c, -widthall)

turtle.done()

技术分享图片

 

谢谢

Python之turtle画同心圆和棋盘

标签:hal   image   tle   棋盘   info   speed   got   pytho   span   

原文地址:https://www.cnblogs.com/zhzhang/p/9903239.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!