python中绘制一个正方形和一个六边形代码
时间: 2024-05-09 13:17:30 浏览: 105
用PYTHON中的TURTLE模块绘图(11.10更新).pdf
以下是绘制正方形和六边形的Python代码:
绘制正方形:
```
import turtle
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.done()
```
绘制六边形:
```
import turtle
turtle.forward(100)
turtle.right(60)
turtle.forward(100)
turtle.right(60)
turtle.forward(100)
turtle.right(60)
turtle.forward(100)
turtle.right(60)
turtle.forward(100)
turtle.right(60)
turtle.forward(100)
turtle.right(60)
turtle.done()
```
阅读全文