#!/Library/Frameworks/Python.framework/Versions/Current/bin/python # L-23 MCS 275 Fri 5 Mar 2010 : web_det.py import cgi def PrintHeader(title): """ writes title and header of page """ print """Content-type: text/html %s """ % title def AskDimension(): """ form to enter the dimension """ print """

Give dimension:

""" def AskMatrix(n): """ form to enter an n-by-n matrix """ print """
""" print """The dimension: """ % n print "

Enter matrix :

" print "" for i in range(0,n): print "" for j in range(0,n): print """""" % (i,j) print "
" print """""" print "
" def main(): """ web interface to compute a determinant """ PrintHeader("compute determinant") AskDimension() form = cgi.FieldStorage() if form.has_key("dim"): n = int(form["dim"].value) AskMatrix(n) print "\n" main()