# Program to draw a bunch of random colored circles # Required Libraries from random import randrange from graphics import * # creates a Circle centered at point (x, y) of radius def makeCircle(x, y, r): return Circle(Point(x, y), r) # creates a new color using random RGB values def makeColor(): red = randrange(0, 256) green = randrange(0, 256) blue = randrange(0, 256) return color_rgb(red, green, blue) # Create and display a graphics def main(): width = 500 height = 500 myWindow = GraphWin('Circles', width, height) myWindow.setBackground('white') # draw a bunch of random circles with random colors. N = 500 for i in range(N): # pick random center point and radius in the window x = randrange(0,width) y = randrange(0,height) r = randrange(5, 25) c = makeCircle(x, y, r) # select a random color c.setFill(makeColor()) # draw the circle c.draw(myWindow) main()