使用python画出一个飞机
时间: 2023-03-13 21:06:59 浏览: 336
我可以给你一个简单的示例,使用python编写程序来画出一架飞机:from turtle import *# 正方形
forward(100)
left(90)
forward(100)
left(90)
forward(100)
left(90)
forward(100)
left(90)# 尾翼
penup()
left(60)
forward(50)
left(120)
pendown()
forward(50)
left(120)
forward(50)
right(120)
forward(50)# 机头
penup()
left(90)
forward(50)
pendown()
right(90)
forward(50)
left(90)
forward(25)# 左翼
penup()
backward(50)
right(90)
forward(50)
right(90)
pendown()
forward(50)# 右翼
penup()
left(90)
forward(50)
right(90)
pendown()
forward(50)# 左发动机
penup()
backward(50)
right(90)
forward(25)
right(90)
pendown()
circle(25)# 右发动机
penup()
forward(50)
right(90)
forward(25)
right(90)
pendown()
circle(25)done()
相关问题
用简单python画一个飞机
可以使用turtle库来绘制一个简单的飞机,代码示例如下:
```python
import turtle
# 创建画布
t = turtle.Turtle()
t.speed(0)
# 绘制机身
t.penup()
t.goto(-50, 0)
t.pendown()
t.setheading(0)
t.forward(100)
t.setheading(90)
t.forward(20)
t.setheading(180)
t.forward(100)
# 绘制机翼
t.penup()
t.goto(0, 20)
t.pendown()
t.setheading(-45)
t.forward(70)
t.setheading(180)
t.forward(50)
t.setheading(45)
t.forward(70)
# 绘制尾翼
t.penup()
t.goto(40, 0)
t.pendown()
t.setheading(90)
t.forward(30)
t.setheading(0)
t.forward(30)
t.setheading(-90)
t.forward(30)
# 绘制窗户
t.penup()
t.goto(-20, 10)
t.pendown()
t.dot(20)
# 隐藏画笔
t.hideturtle()
turtle.done()
```
运行代码,即可在屏幕上看到绘制的飞机。你还可以根据自己的需求修改代码,让飞机更加逼真。
写一段python代码,画出一个飞机
# 用 Python 画出一架飞机
import turtle t = turtle.Turtle() t.shape("turtle")
t.color("green")
t.speed(3) t.up()
t.goto(0, 0)
t.down() t.begin_fill()
t.forward(200)
t.left(90)
t.forward(50)
t.left(90)
t.forward(400)
t.right(135)
t.forward(100)
t.right(90)
t.forward(100)
t.right(135)
t.forward(400)
t.left(90)
t.forward(50)
t.end_fill() t.up()
t.goto(-150, 50)
t.down()
t.begin_fill()
t.circle(20)
t.end_fill() t.up()
t.goto(150, 50)
t.down()
t.begin_fill()
t.circle(20)
t.end_fill() t.up()
t.goto(0, -100)
t.down()
t.right(90)
t.forward(100) t.up()
t.goto(0, -150)
t.down()
t.right(45)
t.forward(50)
t.right(90)
t.forward(50) t.done()
相关推荐
![](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)