"""五角星"""import turtle as t
import random
defdrawStar(x, y):
t.speed(3)
t.penup()
t.goto(x, y)
t.pendown()for i inrange(5):
r = random.random()
g = random.random()
b = random.random()
t.pencolor((r, g, b))
t.forward(200)
t.right(144)# 右转144°
t.hideturtle()for x inrange(-200,100,50):
drawStar(x,0)
import turtle as t
import random
defdrawStar(x, y):
t.speed(3)
t.penup()
t.goto(x, y)
t.pendown()
t.begin_fill()for i inrange(5):
r = random.random()
g = random.random()
b = random.random()
t.pencolor((r, g, b))
t.fillcolor((r, g, b))
t.forward(200)
t.right(144)# 右转144°
t.end_fill()
t.hideturtle()for x inrange(-200,100,50):
drawStar(x,0)