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 draw_square(t, sz): """Make turtle t draw a square of with side sz.""" for i in range(4): t.forward(sz) t.left(90) def draw_poly(t, n, sz): """Make turtle t draw a regular polygon of n sides of length sz.""" for i in range(n): t.forward(sz) t.left(360/n) wn = turtle.Screen() wn.bgcolor("lightgreen") wn.title("Alex meets a function") tess = turtle.Turtle() tess.color("blue") tess.pensize(3) size = 20 for i in range(15): draw_square(tess, size) size = size + 10 tess.forward(10) tess.right(18) wn.mainloop()

Questions about programming?Chat with your personal AI assistant