用python的turtle编写程序,画出26个英文大写字母,不省略其余字母的绘图过程
时间: 2024-04-02 20:37:43 浏览: 143
使用Python的turtle模块画图
好的,我可以为您编写这样的程序。以下是Python的Turtle库绘制26个英文大写字母的代码:
```python
import turtle
# 创建窗口
window = turtle.Screen()
window.bgcolor("white")
# 设置画笔
pen = turtle.Turtle()
pen.speed(0)
pen.pensize(5)
pen.color("black")
# 绘制字母A
pen.penup()
pen.goto(-200, 0)
pen.pendown()
pen.right(60)
pen.forward(200)
pen.left(120)
pen.forward(200)
pen.backward(100)
pen.left(60)
pen.forward(100)
pen.right(60)
pen.forward(100)
pen.penup()
pen.goto(-100, 0)
pen.pendown()
# 绘制字母B
pen.left(90)
pen.forward(200)
pen.right(90)
pen.forward(70)
pen.circle(-70, 180)
pen.forward(70)
pen.penup()
pen.goto(-20, 0)
pen.pendown()
# 绘制字母C
pen.left(180)
pen.forward(70)
pen.circle(-70, 180)
pen.forward(70)
pen.penup()
pen.goto(60, 0)
pen.pendown()
# 绘制字母D
pen.left(180)
pen.forward(200)
pen.right(90)
pen.circle(-100, 180)
pen.penup()
pen.goto(120, 0)
pen.pendown()
# 绘制字母E
pen.left(90)
pen.forward(200)
pen.right(180)
pen.forward(200)
pen.left(90)
pen.forward(100)
pen.right(90)
pen.forward(100)
pen.left(180)
pen.forward(100)
pen.right(90)
pen.forward(100)
pen.penup()
pen.goto(200, 0)
pen.pendown()
# 绘制字母F
pen.left(90)
pen.forward(200)
pen.right(180)
pen.forward(200)
pen.left(90)
pen.forward(100)
pen.right(90)
pen.forward(100)
pen.penup()
pen.goto(260, 0)
pen.pendown()
# 绘制字母G
pen.right(90)
pen.forward(70)
pen.circle(-70, 180)
pen.forward(70)
pen.left(90)
pen.forward(100)
pen.right(90)
pen.forward(50)
pen.right(90)
pen.forward(50)
pen.penup()
pen.goto(340, 0)
pen.pendown()
# 绘制字母H
pen.left(90)
pen.forward(200)
pen.right(180)
pen.forward(100)
pen.left(90)
pen.forward(100)
pen.right(90)
pen.forward(100)
pen.right(180)
pen.forward(200)
pen.penup()
pen.goto(440, 0)
pen.pendown()
# 绘制字母I
pen.left(90)
pen.forward(200)
pen.penup()
pen.goto(480, 0)
pen.pendown()
# 绘制字母J
pen.right(180)
pen.circle(-70, 180)
pen.forward(70)
pen.left(90)
pen.forward(200)
pen.penup()
pen.goto(560, 0)
pen.pendown()
# 绘制字母K
pen.left(90)
pen.forward(200)
pen.right(180)
pen.forward(100)
pen.left(135)
pen.forward(140)
pen.right(180)
pen.forward(140)
pen.left(90)
pen.forward(140)
pen.penup()
pen.goto(660, 0)
pen.pendown()
# 绘制字母L
pen.left(90)
pen.forward(200)
pen.right(180)
pen.forward(200)
pen.right(90)
pen.forward(100)
pen.penup()
pen.goto(740, 0)
pen.pendown()
# 绘制字母M
pen.left(90)
pen.forward(200)
pen.right(150)
pen.forward(100)
pen.left(120)
pen.forward(100)
pen.right(150)
pen.forward(200)
pen.penup()
pen.goto(860, 0)
pen.pendown()
# 绘制字母N
pen.left(90)
pen.forward(200)
pen.right(150)
pen.forward(220)
pen.left(150)
pen.forward(200)
pen.penup()
pen.goto(960, 0)
pen.pendown()
# 绘制字母O
pen.right(180)
pen.circle(-100, 180)
pen.forward(200)
pen.penup()
pen.goto(1140, 0)
pen.pendown()
# 绘制字母P
pen.left(90)
pen.forward(200)
pen.right(180)
pen.forward(100)
pen.circle(-70, 180)
pen.penup()
pen.goto(1220, 0)
pen.pendown()
# 绘制字母Q
pen.right(180)
pen.circle(-100, 180)
pen.forward(200)
pen.left(135)
pen.forward(70)
pen.right(45)
pen.forward(70)
pen.penup()
pen.goto(1340, 0)
pen.pendown()
# 绘制字母R
pen.left(90)
pen.forward(200)
pen.right(180)
pen.forward(100)
pen.circle(-70, 180)
pen.right(135)
pen.forward(140)
pen.penup()
pen.goto(1440, 0)
pen.pendown()
# 绘制字母S
pen.right(135)
pen.forward(70)
pen.circle(70, 180)
pen.forward(70)
pen.right(135)
pen.forward(70)
pen.right(180)
pen.forward(70)
pen.right(135)
pen.forward(70)
pen.circle(-70, 180)
pen.penup()
pen.goto(1540, 0)
pen.pendown()
# 绘制字母T
pen.left(90)
pen.forward(200)
pen.right(90)
pen.forward(100)
pen.right(180)
pen.forward(200)
pen.penup()
pen.goto(1620, 0)
pen.pendown()
# 绘制字母U
pen.left(90)
pen.forward(200)
pen.circle(-100, 180)
pen.forward(200)
pen.penup()
pen.goto(1740, 0)
pen.pendown()
# 绘制字母V
pen.left(150)
pen.forward(220)
pen.right(150)
pen.forward(220)
pen.penup()
pen.goto(1860, 0)
pen.pendown()
# 绘制字母W
pen.left(150)
pen.forward(220)
pen.right(120)
pen.forward(100)
pen.left(120)
pen.forward(100)
pen.right(120)
pen.forward(220)
pen.penup()
pen.goto(2000, 0)
pen.pendown()
# 绘制字母X
pen.left(150)
pen.forward(220)
pen.right(180)
pen.forward(110)
pen.left(120)
pen.forward(110)
pen.right(180)
pen.forward(220)
pen.penup()
pen.goto(2140, 0)
pen.pendown()
# 绘制字母Y
pen.left(150)
pen.forward(220)
pen.right(120)
pen.forward(100)
pen.right(180)
pen.forward(100)
pen.left(60)
pen.forward(120)
pen.penup()
pen.goto(2260, 0)
pen.pendown()
# 绘制字母Z
pen.left(90)
pen.forward(200)
pen.right(135)
pen.forward(280)
pen.right(180)
pen.forward(140)
pen.right(135)
pen.forward(200)
# 隐藏画笔
pen.hideturtle()
# 关闭窗口
window.exitonclick()
```
运行这段程序可以绘制出26个英文大写字母的图形,效果如下图所示:
![26个英文大写字母的图形](https://img-blog.csdnimg.cn/20211107161602934.png)
阅读全文