turtle库写中国矿业大学
时间: 2023-09-04 07:11:23 浏览: 174
可以使用turtle库的penup()和pendown()方法来控制画笔的移动和停止,还可以使用goto()方法来移动画笔到指定的位置。以下是使用turtle库画出“中国矿业大学”的示例代码:
```python
import turtle
# 设置画笔
turtle.penup()
turtle.goto(-200, 0)
turtle.pendown()
turtle.pensize(10)
# 画“中”
turtle.left(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(200)
# 画“国”
turtle.penup()
turtle.goto(-50, 0)
turtle.pendown()
turtle.left(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
# 画“矿”
turtle.penup()
turtle.goto(100, 100)
turtle.pendown()
turtle.left(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(100)
# 画“业”
turtle.penup()
turtle.goto(100, -100)
turtle.pendown()
turtle.left(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
# 画“大”
turtle.penup()
turtle.goto(250, 0)
turtle.pendown()
turtle.left(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(100)
# 画“学”
turtle.penup()
turtle.goto(400, 0)
turtle.pendown()
turtle.left(90)
turtle.forward(200)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
```
执行上述代码后,就可以在turtle窗口中看到绘制出来的“中国矿业大学”字样了。
阅读全文