from array import array open the text file for reading gradefile openfilename"rextract the first two values which indicate the size of the array numexams intgradefile readline(numstudents intgradefile readline(create the - array to store the grades examgrades array dnumstudentsnumexams extract the grades from the remaining lines for student in gradefile grades student split(for in rangenumexams )examgrades[ ,jintgrades[ji + close the text file gradefile close(with the grades extracted from the file and stored in the - arraywe can now process the grades as needed suppose we want to compute and display each student' exam gradewhich we can do with the following codecompute each student' average exam grade for in rangenumstudents tally the exam grades for the ith student total for in rangenumexams total +examgrades[ ,jcompute average for the ith student examavg total numexams print"% % ( + examavgimplementing the - array we now turn our attention to the implementation of the - array there are several approaches that we can use to store and organize the data for - array two of the more common approaches include the use of single - array to physically store the elements of the - array by arranging them in order based on either row or columnwhereas the other uses an array of arrays we are going to use the latter approach to implement the array abstract data type and delay discussion of the former approach until later in the when using an array of arrays to store the elements of - arraywe store each row of the - array within its own - array thenanother - array is used to store references to each of the arrays used to store the row elements figure shows the abstract view of - array and the physical storage of that - array using an array of arrays