python海龟作图经典100例
时间: 2023-07-21 14:42:38 浏览: 250
python海龟绘图实例教程
5星 · 资源好评率100%
好的,以下是 Python 海龟作图经典100例:
1. 画一个正方形
```python
import turtle
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
```
2. 画一个圆形
```python
import turtle
turtle.circle(50)
```
3. 画一个三角形
```python
import turtle
turtle.forward(100)
turtle.right(120)
turtle.forward(100)
turtle.right(120)
turtle.forward(100)
```
4. 画一个五角星
```python
import turtle
for i in range(5):
turtle.forward(100)
turtle.right(144)
```
5. 画一个六边形
```python
import turtle
for i in range(6):
turtle.forward(100)
turtle.right(60)
```
6. 画一个螺旋线
```python
import turtle
for i in range(100):
turtle.forward(i)
turtle.right(10)
```
7. 画一个椭圆
```python
import turtle
turtle.circle(100, 90)
turtle.circle(50, 90)
turtle.circle(100, 90)
turtle.circle(50, 90)
```
8. 画一个心形
```python
import turtle
turtle.left(45)
turtle.forward(100)
turtle.circle(50, 180)
turtle.right(90)
turtle.circle(50, 180)
turtle.forward(100)
```
9. 画一个海龟壳
```python
import turtle
turtle.circle(50, 180)
turtle.left(90)
turtle.circle(50, 180)
turtle.right(90)
turtle.circle(50, 180)
turtle.right(90)
turtle.circle(50, 180)
```
10. 画一个蝴蝶
```python
import turtle
turtle.left(90)
turtle.circle(100, 45)
turtle.circle(50, 180)
turtle.right(90)
turtle.circle(50, 180)
turtle.circle(100, 45)
```
阅读全文