solving math problems with Python