编写python代码用turtle库画字母WLXY
时间: 2024-05-08 19:07:44 浏览: 82
维吾尔语字母雨python代码
import turtle
# 创建一个画布
canvas = turtle.Screen()
# 创建一个海龟对象
pen = turtle.Turtle()
# 设置画笔宽度和颜色
pen.pensize(5)
pen.color("red")
# 画字母W
pen.left(60)
pen.forward(100)
pen.right(120)
pen.forward(100)
pen.left(120)
pen.forward(100)
pen.right(120)
pen.forward(100)
# 画字母L
pen.up()
pen.goto(150,0)
pen.down()
pen.left(90)
pen.forward(100)
pen.right(90)
pen.forward(50)
# 画字母X
pen.up()
pen.goto(225,0)
pen.down()
pen.left(45)
pen.forward(70)
pen.up()
pen.goto(225,0)
pen.down()
pen.right(45)
pen.forward(70)
# 画字母Y
pen.up()
pen.goto(300,0)
pen.down()
pen.left(90)
pen.forward(50)
pen.left(45)
pen.forward(50)
pen.up()
pen.goto(300,0)
pen.down()
pen.right(45)
pen.forward(50)
# 隐藏画笔
pen.hideturtle()
# 关闭画布
canvas.exitonclick()
阅读全文