Python-画图
程序员文章站
2023-09-28 19:30:51
画图 蟒蛇绘制,和函数封装 去掉注释即可运行 ......
画图
蟒蛇绘制,和函数封装
去掉注释即可运行
# drawpython ''' import turtle # 绘制坐标系 turtle.setup(650,350,200,200) 画笔控制 turtle.penup() # 向当前方向前进 turtle.fd(-250) 画笔控制 turtle.pendown() turtle.pensize(25) turtle.pencolor("purple") # 改变绘制方向 turtle.seth(-40) # circle3:画圆第一个参数:半径 第二个参数:弧度 for i in range(4): turtle.circle(40,80) turtle.circle(-40,80) turtle.circle(40,80/2) turtle.fd(40) turtle.circle(16,180) turtle.fd(40*2/3) ''' ''' # 代码改进 from turtle import * setup(650,350,200,200) penup() fd(-250) pendown() pensize(25) pencolor("green") seth(-40) for i in range(4): circle(40,80) circle(-40,80) circle(40,80/2) fd(40) circle(16,180) fd(40*2/3) ''' # 函数封装 ''' import turtle def drawsnake(radius, angle, length): turtle.seth(-40) for i in range(length): turtle.circle(radius, angle) turtle.circle(-radius, angle) turtle.circle(radius, angle/2) turtle.fd(40) turtle.circle(16, 180) turtle.fd(40* 2/3) turtle.setup(650, 350, 200, 200) turtle.penup() turtle.fd(-250) turtle.pendown() turtle.pensize(25) turtle.pencolor("purple") drawsnake(40, 80, 4) turtle.done() '''
上一篇: Python第五十一天 python2升级为python3
下一篇: 数据连接