The number you’re asking math.exp to calculate has, in decimal, over 110,000 digits. That’s slightly outside of the range of a double, so it causes an overflow.
To fix it use:
try:
ans = math.exp(200000)
except OverflowError:
ans = float(‘inf’)