Home  >  Article  >  Backend Development  >  How to draw a square spiral in python

How to draw a square spiral in python

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-06-24 16:15:3628234browse

How to draw a square spiral in python

How to draw a square spiral in python? Here are the specific painting steps:

The first step is to click on the menu bar and enter idle.

How to draw a square spiral in python

The second step is to open the shell, create a new file and name it.

Related recommendations: "Python Video Tutorial"

How to draw a square spiral in python

##The third step is to import the turtle module and start writing code.


The code is as follows:

import turtle
turtle.setup(400,400,0,0)
turtle.speed(10)
turtle.pensize(2)
for x in range(100):
    turtle.forward(2*x)
    turtle.left(90)
turtle.done()

The fourth step is to display the renderings.

How to draw a square spiral in python

The above is the detailed content of How to draw a square spiral in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn