In this post, we will understand Draw Square and rotated Square in Python Turtle graphic with examples.To use a Turtle library make sure its installed on local system or else install it using command “pip install PythonTurtle” once installed import in our program using import Turtle
from turtle import Turtle, Screen
BASE_UNIT = 20
def StartDrawing(turtle, start, stop, step):
for x in range(start, stop + 1, step):
for y in range(start, stop + 1, step):
turtle.goto(x * BASE_UNIT, y * BASE_UNIT)
turtle.stamp()
turtle.left(45)
turtle.stamp()
square = Turtle(shape="square")
square.shapesize(8)
square.color("Blue")
square.penup()
StartDrawing(square, -12, 12, 12)
tess = Turtle(shape="square")
tess.shapesize(4)
tess.color("gold")
tess.penup()
StartDrawing(tess, -6, 6, 12)
screen = Screen()
screen.exitonclick()
output
