五角星

1+
import turtle
import random

def draw_star(x):
    turtle.pendown()
    turtle.begin_fill()
    for z in range(5):
        turtle.fd(x)
        turtle.right(144)
    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 = random.randint(10,150)
    x = random.randint(-400,400)
    y = random.randint(-300,300)
    turtle.goto(x,y)
    draw_star(d)

1+

发表评论