python写一个放烟花的生日祝福
时间: 2023-07-25 16:48:39 浏览: 714
好的,以下是一个简单的Python程序,用于放烟花的生日祝福:
```python
import random
import time
def firework():
colors = ["红色", "黄色", "绿色", "蓝色", "紫色", "橙色"]
shapes = ["圆形", "星形", "心形", "三角形", "方形", "菱形"]
color = random.choice(colors)
shape = random.choice(shapes)
print(f"放出一个{color}的{shape}烟花!")
def happy_birthday():
print("祝你生日快乐!")
time.sleep(2)
print("让我们放些烟花庆祝吧!")
time.sleep(1)
for i in range(5):
firework()
time.sleep(1)
happy_birthday()
```
运行以上代码,将会输出一段简单的生日祝福,并且会放出五个随机颜色和形状的烟花庆祝。
阅读全文