定义函数花正多边形

0

from turtle import Turtle,Screen

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

cs=['red','yellow','blue','orange','cyan','pink','purple','green']

screen=Screen()
screen.delay(0)
screen.bgcolor('black')

t=Turtle()
t.pensize(10)
t.speed(0)

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

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

<\pre>

0

发表评论