python绘制多彩N边形(turtle)

python绘制多彩N边形(turtle)

import turtlefrom tkinter import *from tkinter.simpledialog import *turtle.bgcolor("black")# You can choose between 2 and 6 sides for some cool shapes!a = askinteger(title="输入边数:",prompt="请输入边数,范围2-6:",initialvalue="",minvalue=2,maxvalue=6)sides=acolors=["red","yellow", "blue", "orange","green","purple"]for x in range(200): turtle.color(colors[x%sides]) turtle.forward(x*3/sides x) turtle.left(360/sides 1) turtle.width(x*sides/200)turtle.done()