def test_calculateAllocat(self):

        array2d = Array2D(75, 100)
        print(sys.getsizeof(array2d._theRows[0]))

        array2d = Array2D(10000, 25)
        print(sys.getsizeof(array2d))

        array2d = Array2D(10000, 10000)
        print(sys.getsizeof(array2d))

        # array2d list
        array2dlist = Array2DList(75, 100)
        print(sys.getsizeof(array2dlist))

        print(sys.getsizeof(Array(75)))
        print(sys.getsizeof([1] * 75 * 100))
示例#2
0
 def test__init__(self):
     array2d = Array2D(2, 2)
from array import Array2D

gradeFile = open("../exam grades", "r")

numStudnets = int(gradeFile.readline())
numExams = int(gradeFile.readline())

examGrades = Array2D(numStudnets, numExams)

i = 0
for student in gradeFile:
    grades = student.split()
    for j in range(numExams):
        examGrades[i, j] = int(grades[j])
    i += 1

gradeFile.close()

for i in range(numStudnets):
    total = 0
    for j in range(numExams):
        total += examGrades[i,j]

    examAvg = total / numExams
    print("%2d:  %6.2f" % (i+1, examAvg))
示例#4
0
 def __init__(self, numRows, numCols):
     self._theGrid = Array2D(numRows, numCols)
     self._theGrid.clear(0)
示例#5
0
	def __init__(self, numRows, numCols):
		self._mazeCells = Array2D(numRows, numCols)
		self._startCell = None
		self._exitCell = None
 def __init__(self, numRows, numCols):
     "Creates a matrix"
     self._theGrid = Array2D(numRows, numCols)
     self._theGrid.clear(0)
 def __init__(self, numRows, numCols):
     "create"
     self._grid = Array2D(numRows, numCols)
     self.configure(list())
示例#8
0
 def __init__(self, numRows, numCols):
     # Allocate the 2-D array for the grid.
     self._grid = Array2D(numRows, numCols)
     # Clear the grid and set all cells to dead.
     self.configure(list())