用Python的turtle模块画一个“LCY”字样
时间: 2024-05-24 13:12:07 浏览: 107
使用Python的turtle模块画图
以下是用Python的turtle模块画出“LCY”字样的代码:
```python
import turtle
# 设置画笔宽度和颜色
turtle.pensize(10)
turtle.pencolor("blue")
# 画L
turtle.left(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(50)
# 画C
turtle.penup()
turtle.forward(50)
turtle.pendown()
turtle.circle(50)
# 画Y
turtle.penup()
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.pendown()
turtle.right(45)
turtle.forward(70)
turtle.right(180)
turtle.forward(70)
turtle.left(90)
turtle.forward(70)
# 隐藏画笔
turtle.hideturtle()
# 等待用户关闭窗口
turtle.done()
```
运行以上代码,就能在窗口中看到“LCY”字样的图形,如下所示:
![LCY](https://cdn.luogu.com.cn/upload/image_hosting/wk8j8p6d.png)
阅读全文