#!/usr/bin/env python from math import sin,cos,radians radius = 17 steps = 90 angle_increment = 90/steps grid = [] for n in range(0,(90/angle_increment) + 1): angle = n * angle_increment x = int(sin(radians(angle)) * radius) y = int(cos(radians(angle)) * radius) if (x,y) not in grid: grid.append((x,y)) rows = [] for row in range(radius,-1,-1): thisrow = "" # top half for col in range(0,radius+1): if(col,row) in grid: thisrow += "O" else: thisrow += "." # mirror thisrow and prefix it to thisrow (add top left quadrant) thisrow = thisrow[1:radius+1][::-1] + thisrow rows.append(thisrow) #print top hemisphere for row in rows: print row #print bottom hemisphere (reverse it -> chop first element off) for row in rows[::-1][1:radius+1]: print row