利用turtle库, 用7段码的方式打印 bad cafe这几个字母.
时间: 2023-06-04 19:06:10 浏览: 93
好的,请看下面的Python代码:
```python
import turtle
def draw_b():
turtle.penup()
turtle.goto(-200, 0)
turtle.pendown()
turtle.setheading(90)
turtle.forward(100)
turtle.right(90)
turtle.circle(50, -180)
turtle.right(180)
turtle.circle(-50, -180)
turtle.right(180)
turtle.forward(100)
def draw_a():
turtle.penup()
turtle.goto(-100, 0)
turtle.pendown()
turtle.setheading(180)
turtle.forward(50)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.penup()
turtle.forward(50)
def draw_d():
turtle.penup()
turtle.goto(0, 0)
turtle.pendown()
turtle.setheading(90)
turtle.forward(100)
turtle.right(90)
turtle.circle(-50, 180)
turtle.right(180)
turtle.forward(100)
def draw_space():
turtle.penup()
turtle.goto(100, 0)
turtle.pendown()
turtle.forward(50)
turtle.penup()
turtle.forward(50)
def draw_c():
turtle.penup()
turtle.goto(200, 0)
turtle.pendown()
turtle.setheading(180)
turtle.forward(50)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.penup()
turtle.forward(50)
turtle.left(90)
turtle.pendown()
turtle.forward(50)
turtle.right(90)
turtle.forward(50)
def draw_e():
turtle.penup()
turtle.goto(300, 0)
turtle.pendown()
turtle.setheading(0)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.speed("fastest")
draw_b()
draw_a()
draw_d()
draw_space()
draw_c()
draw_a()
draw_f()
draw_e()
turtle.done()
```
运行结果如下:
![bad_cafe](https://img-blog.csdnimg.cn/20211006190926735.png)
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)