While there is nothing wrong with your solution, this is a bit more performant
from graphics import * def main(): win = GraphWin("Patch2" ,100,100) coords = [5, 15, 25, 40, 50, 60, 75, 85, 95] centers = set([coords[i] for i in range(1, len(coords), 3)]) for i in xrange(len(coords)): for j in xrange(i+1): x, y = (coords[i], coords[j]) c1 = Circle(Point(x+2,y), 5) c2 = Circle(Point(y+2,x), 5) c1.draw(win) c2.draw(win) if x in centers and y in centers: c1.setFill("White") c2.setFill("White") else: c1.setFill("Red") c2.setFill("Red") main()
Update: "Better" version
And since I got bored and I liked this problem (yes, I program when I'm bored) I made a fully parameter-ized version which you can do some fun stuff with, like.

Probably over your head :) But maybe you learn something from it, so I'm posting it.
from graphics import * def drawPattern(scale): # Inner method: Draw a square of circles given the top-left point def drawSquare(win, xCoord, yCoord, squareSize=30, numCircles=3, scale=1, scaleCircles=False, outer_color="Red", inner_color="White"): # Overwrite the default scaling if scale > 1: squareSize *= scale if scaleCircles: numCircles *= scale radius = squareSize/(numCircles*2) # Divide by 2 since it's the radius from math import sqrt, floor centerDiff = (2*radius) * floor(sqrt(numCircles)) # Used for drawing off-color circles # xrange uses an exclusive stop value, so go one value past to make inclusive for x in xrange(radius, squareSize+radius, radius*2): for y in xrange(squareSize-radius, x-radius, -radius*2): c1 = Circle(Point(x+xCoord+2,y+yCoord), radius) c2 = Circle(Point(y+yCoord+2,x+xCoord), radius) c1.draw(win) c2.draw(win) if (centerDiff < x < squareSize - centerDiff) and (centerDiff < y < squareSize - centerDiff): c1.setFill(inner_color) c2.setFill(inner_color) else: c1.setFill(outer_color) c2.setFill(outer_color) win = GraphWin("Patch2 (x{})".format(scale), 100*scale,100*scale) coords = [0, 35, 70] for x in coords: for y in coords: drawSquare(win, x*scale, y*scale, scale=scale) # normal (boring) version # drawSquare(win, x*scale, y*scale, scale=scale, scaleCircles=True, outer_color="Blue") # Picture version def main(): drawPattern(3) main()