用python写一个“杨天麒五一快乐”的烟花绽放代码
时间: 2023-06-04 10:05:20 浏览: 64
好的,以下是Python代码,可以运行出一个“杨天麒五一快乐”的烟花绽放效果:
```python
import turtle
import random
turtle.speed("fastest")
colors = ["red", "blue", "green", "purple", "orange", "pink", "yellow"]
def draw_star(size, color):
turtle.color(color)
turtle.begin_fill()
for side in range(5):
turtle.forward(size)
turtle.right(144)
turtle.end_fill()
def draw_firework():
x, y = random.randint(-300, 300), random.randint(-200, 200)
turtle.up()
turtle.goto(x, y)
turtle.down()
size = random.randint(20, 80)
color = random.choice(colors)
draw_star(size, color)
turtle.write("杨天麒五一快乐!", align="center", font=("Arial", 24, "bold"))
while True:
draw_firework()
```
希望你喜欢这个小程序!