Draw squares in turtle library in Python

Draw squares in turtle library in Python

import turtle as t#Give the turtle library an nickname of t
for i in range(2):#Use a for loop to traverse
t.forward(50)
#Draw a line according to the front angle t.right(90)#The brush rotates to the right
t .backward(50)
#Draw a line according to the right rear angle t.right(90)
#The brush rotates to the right t.done()#Keep the window = turtle.done()
Insert picture description here

Actually it's almost the same as drawing a triangle

Guess you like

Origin blog.csdn.net/qq_44948696/article/details/108458979