from cs1graphics import * numLevels = 8 # number of levels unitSize = 12 # the height of one level screenSize = unitSize * (numLevels + 1) paper = Canvas(screenSize, screenSize) width = unitSize # for first level centerX = screenSize - unitSize # for first level centerY = unitSize # for first level # create levels from top to bottom for level in range(numLevels): block = Rectangle(width, unitSize) # height is always unitSize block.move(centerX, centerY) block.setFillColor('gray') paper.add(block) # update parameters width += unitSize centerY += unitSize centerX -= unitSize/2