Cody Bable

Generation

generate functionFri, 28 Apr 2023

create a function to store the mouse clicks and redraw from the mouse clicks in turtle.

def drawSquare(t, sz): """Make turtle t draw a square of with side sz.""" for i in range(4): t.forward(sz) t.left(90) wn = turtle.Screen() # Set up the window and its attributes wn.bgcolor("lightgreen") wn.title("Alex meets a function") tess = turtle.Turtle() # create tess and set some attributes tess.pensize(3) size = 20 # size of the smallest square for i in range(5): drawSquare(tess, size) size = size + 20 # increase the size for next time tess.forward(10) # move tess along a little tess.right(18) # and give her some extra turn wn.mainloop()

Questions about programming?Chat with your personal AI assistant