用turtle库画一个黄色的wjn
时间: 2024-02-24 14:59:33 浏览: 49
好的,可以参考以下代码绘制一个黄色的“wjn”:
```python
import turtle
# 设置画笔
pen = turtle.Pen()
pen.pensize(5)
pen.speed(5)
# 设置画笔颜色为黄色
pen.color("yellow")
# 画"W"
pen.left(90)
pen.forward(100)
pen.right(135)
pen.forward(50)
pen.left(90)
pen.forward(50)
pen.right(135)
pen.forward(100)
# 移动到下一个字母的起始位置
pen.penup()
pen.left(90)
pen.forward(50)
pen.right(90)
pen.forward(20)
pen.pendown()
# 画"J"
pen.circle(30, 180)
pen.right(90)
pen.forward(60)
# 移动到下一个字母的起始位置
pen.penup()
pen.right(90)
pen.forward(20)
pen.left(90)
pen.forward(100)
pen.left(90)
pen.forward(20)
pen.pendown()
# 画"N"
pen.left(90)
pen.forward(100)
pen.right(145)
pen.forward(110)
pen.left(145)
pen.forward(100)
# 隐藏画笔
pen.hideturtle()
turtle.done()
```
运行上面的代码,就可以得到一个黄色的由"W"、"J"、"N"三个字母组成的图形。
阅读全文