Python Overflow Error Mathematics Past Question