import math def polar_to_rect(r, theta): x = r * math.cos(theta) y = r * math.sin(theta) return x, y def rect_to_polar(x, y): r = math.sqrt(x**2 + y**2) theta = math.atan(float(y)/float(x)) return r, theta