screen = turtle.Screen()
screen.bgcolor("black")
def create_firework():
colors = ["red", "orange", "yellow", "green", "blue", "purple", "white"]
firework = turtle.Turtle()
firework.shape("circle")
firework.color(random.choice(colors))
firework.shapesize(0.5)
firework.penup()
firework.speed(0)
firework.goto(random.randint(-200, 200), -200)
firework.pendown()
return firework
def explode_firework(firework):
for _ in range(30):
firework.forward(random.randint(1, 10))
firework.right(random.randint(0, 360))
fireworks = []
for _ in range(10):
firework = create_firework()
fireworks.append(firework)
while True:
for firework in fireworks:
explode_firework(firework)
firework.hideturtle()
fireworks.remove(firework)
if len(fireworks) == 0:
break
turtle.done()