1.#Python的turtle绘制正六边形 代码: len=100 #表示边长像素 import turtle as t #正六边形内角都是120度,外角60度 for i in range(6): t.left(60) t.fd(len) t.done() 结果: 2.#Python123 turtle叠边形绘制 Len=150 import turtle as t #叠边形内角为100度,外角就是80度 t.width(10) for i in range(10): t.fd(Len) t…
Example1: import turtle as t #初始设置画笔的宽度(size).颜色(color) t.pensize(5) t.pencolor("black") #循环结构,减少代码 for i in range(4): t.forward(200) t.left(90) Example2: 方法一:把上面绘制四边形的代码:行6中的4改为6即可 #方法二 import turtle as t t.pensize(5) t.pencolor("black&quo…
代码实现: #绘制彩色螺旋线 import turtle import time turtle.pensize(2) turtle.bgcolor("black") colors = ["red","yellow","purple","blue"] turtle.tracer(False) for x in range(400): turtle.forward(2*x) turtle.color(color…