定义函数画正多边形彩图

1+

from turtle import Turtle,Screen

cs = [‘blue’,’light blue’,’yellow’,’orange’,’grey’]

def draw_polygon(haigui,n,length,k):
for x in range(n):
haigui.fd(length)
haigui.left(k * 360/n)

screen = Screen()
screen.delay(0)

t = Turtle()
t.pensize(10)

for n in range(3,10):
t.color(cs[n%5])
draw_polygon(t,n,100,1)
for n in range(3,10):
t.color(cs[n%5])
draw_polygon(t,n,100,-1)

1+

发表评论