quick look at machine learning def compareanimals(animalsprecision)"""assumes animals is list of animalsprecision an int > builds table of euclidean distance between each animal""#get labels for columns and rows columnlabels [for in animalscolumnlabels append( getname()rowlabels columnlabels[:tablevals [#get distances between pairs of animals #for each row for in animalsrow [#for each column for in animalsif = row append('--'elsedistance distance( row append(str(round(distanceprecision))tablevals append(row#produce table table pylab table(rowlabels rowlabelscollabels columnlabelscelltext tablevalscellloc 'center'loc 'center'colwidths [ ]*len(animals)table scale( pylab axis('off'#don' display and -axes pylab savefig('distances'figure build table of distances between pairs of animals the code uses pylab plotting facility that we have not previously usedtable the table function produces plot that (surprise!looks like table the keyword arguments rowlabels and collabels are used to supply the labels (in this example the names of the animalsfor the rows and columns the keyword argument celltext is used to supply the values appearing in the cells of the table in the examplecelltext is bound to tablevalswhich is list of lists of strings each element in tablevals is list of the values for the cells in one row of the table the keyword argument cellloc is used to specify where in each cell the text should appearand the keyword argument loc is used to specify where in the figure the table itself should appear the last keyword parameter used in the example is colwidths it is bound to list of floats giving the width (in inchesof each column in the table the code table scale( instructs pylab to leave the horizontal width of the cells unchangedbut to increase the height of the cells by factor of (so the tables look prettier