# example function (using turtle and random modules) import turtle import random # define a function to draw a polygon/shape def draw_shape(my_turtle, x, y, size, number_sides): my_turtle.penup() my_turtle.goto(x, y) my_turtle.pendown() random_color = random.randint(0, len(colors)-1) my_turtle.color(colors[random_color]) # draw a square for side in range(number_sides): my_turtle.forward(size) my_turtle.right(360 / number_sides) tom = turtle.Turtle() tom.speed("slow") colors = ["red", "pink", "black", "yellow", "cyan", "purple", "green"] draw_shape(tom, -50, 50, 100, 4) draw_shape(tom, -100, 50, 100, 5) draw_shape(tom, -150, 50, 100, 9) draw_shape(tom, -200, 100, 100, 6) turtle.done()