#------------------------------------------------------------------ # table.py # # This Python program illustrates the importing of a Python # library function and the outputting of a numerical table. # # to execute: $ python ./table.py # # programmer: ALLAN CRUSE # written on: 06 MAR 2011 #------------------------------------------------------------------ import math # needed for the 'sqrt()' function # show the table's title print print " A Short Table of Square Roots" print # show the table's headline print " z ", for col in range( 10 ): print " %d " % col, print # show the table's sideline and body z = 0.0 # starting value for z delta_z = 0.01 # size of z increments for row in range( 10 ): print " %1.2f: " % z, for col in range( 10 ): r = math.sqrt( z ) print "%1.3f " % r, z += delta_z print print