帮我用python画一幅升国旗的简笔画
时间: 2023-11-11 22:03:50 浏览: 146
好的,以下是用 Python 画升国旗的简笔画的代码:
```python
import turtle
# 定义画星星的函数
def draw_star(size, color):
turtle.color(color)
turtle.begin_fill()
for _ in range(5):
turtle.forward(size)
turtle.right(144)
turtle.forward(size)
turtle.left(72)
turtle.end_fill()
# 画红色背景
turtle.speed(10)
turtle.color("red")
turtle.begin_fill()
turtle.forward(300)
turtle.right(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(600)
turtle.right(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(300)
turtle.right(90)
turtle.end_fill()
# 画大星星
turtle.penup()
turtle.goto(-120, 80)
turtle.pendown()
draw_star(60, "yellow")
# 画四个小星星
turtle.penup()
turtle.goto(-70, 45)
turtle.pendown()
draw_star(20, "yellow")
turtle.penup()
turtle.goto(-40, 10)
turtle.pendown()
draw_star(20, "yellow")
turtle.penup()
turtle.goto(-70, -25)
turtle.pendown()
draw_star(20, "yellow")
turtle.penup()
turtle.goto(-120, -40)
turtle.pendown()
draw_star(20, "yellow")
turtle.hideturtle()
turtle.done()
```
运行代码后会出现一个画好的升国旗的简笔画,如下图所示:
![升国旗简笔画](https://i.imgur.com/pA5NkWw.png)
阅读全文