#!/usr/bin/env python # encoding: utf-8 # # Copyright (c) 2010 Doug Hellmann. All rights reserved. # """Checking for overflow or infinite values. """ #end_pymotw_header import math print '{:^3} {:6} {:6} {:6}'.format('e', 'x', 'x**2', 'isinf') print '{:-^3} {:-^6} {:-^6} {:-^6}'.format('', '', '', '') for e in range(0, 201, 20): x = 10.0 ** e y = x*x print '{:3d} {!s:6} {!s:6} {!s:6}'.format(e, x, y, math.isinf(y))