Usually in python Matrixes would be two dimensional arrays. Like:
matrix = [[11,12,13,14],[21,22,23,24],[31,32,33,34]]
//is the same as
would give you a matrix like:
11 12 13 14
21 22 23 24
31 32 33 34
so you have an array which stores the rows (the outer array) and one array for each row. To access e.g. the value at position (2,4) which is 24
you would do
matrix[1][3]
as matrix[1] = [21,22,23,24]
and matrix[1][3] = [21,22,23,24][3] = 24
To iterate over your matrix (i.e. your two dimensional array) you can do:
#iterate over the rows
for row in matrix:
#max value
max = max(row)
print max
#if you want to iterate over the elements in the row do:
for element in row:
print element
In Your example you are defining a Matrix class which will be initialized with 3 parameters: i
, j
and value
. You are not doing more. For examples of your own matrix class you could have a look here