五角星

1+

import turtle
from random import randint

def draw_star(x):
      turtle.pendown()
      turtle.begin_fill()
      for z in range(5):
           turtle.rt(144)
           turtle.fd(x)
      turtle.end_fill()
      turtle.penup()

turtle.setup(800,600)
turtle.pensize(5)
turtle.speed(7)
turtle.fillcolor('yellow')

turtle.penup()
for c in range(5):
     d = randint(10,150)
     x = randint(-400,250)
     y = randint(-150,150)
     turtle.goto(x,y)
     draw_star(d)
1+

发表评论