python画个五星红旗
时间: 2023-11-20 09:55:53 浏览: 92
python 实现五星红旗源码
以下是Python画五星红旗的代码:
```python
import turtle
# 设置画布大小
turtle.setup(800, 600)
# 画红色背景
turtle.penup()
turtle.goto(-350, 250)
turtle.pendown()
turtle.color('red')
turtle.begin_fill()
for i in range(2):
turtle.forward(700)
turtle.right(90)
turtle.forward(500)
turtle.right(90)
turtle.end_fill()
# 画大星星
turtle.penup()
turtle.goto(-300, 180)
turtle.pendown()
turtle.color('yellow')
turtle.begin_fill()
for i in range(5):
turtle.forward(100)
turtle.right(144)
turtle.end_fill()
# 画四个小星星
turtle.penup()
turtle.goto(-120, 220)
turtle.pendown()
turtle.begin_fill()
for i in range(5):
turtle.forward(30)
turtle.right(144)
turtle.end_fill()
turtle.penup()
turtle.goto(-70, 170)
turtle.pendown()
turtle.begin_fill()
for i in range(5):
turtle.forward(30)
turtle.right(144)
turtle.end_fill()
turtle.penup()
turtle.goto(-70, 70)
turtle.pendown()
turtle.begin_fill()
for i in range(5):
turtle.forward(30)
turtle.right(144)
turtle.end_fill()
turtle.penup()
turtle.goto(-120, 20)
turtle.pendown()
turtle.begin_fill()
for i in range(5):
turtle.forward(30)
turtle.right(144)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
# 显示画布
turtle.done()
```
阅读全文