m = int(input("Number of matrices: "))
rows = int(input("Enter the Number of rows : "))
column = int(input("Enter the Number of Columns: "))
p = 0
for i in range(0,m):
print("Enter the elements of Matrix:")
matrix_i = [[tuple(map(float, input().split(" "))) for i in range(column)] for i in range(rows)]
p = p + 1
print("Matrix no: ", p)
for n in matrix_i:
print(n)
res = tuple(map(lambda i, j: max(i ,j) , matrix_i, matrix_i))
print(res)
Got the output as:
Number of matrices:
3
Enter the Number of rows :
2
Enter the Number of Columns:
2
Enter the elements of Matrix:
6 7 8
6 8 2
1 2 3
9 0 1
Matrix no: 1
[(6.0, 7.0, 8.0), (6.0, 8.0, 2.0)]
[(1.0, 2.0, 3.0), (9.0, 0.0, 1.0)]
Enter the elements of Matrix:
7 4 8
5 2 8
9 3 6
0 0 0
Matrix no: 2
[(7.0, 4.0, 8.0), (5.0, 2.0, 8.0)]
[(9.0, 3.0, 6.0), (0.0, 0.0, 0.0)]
Enter the elements of Matrix:
1 2 3
5 6 7
8 4 3
8 6 4
Matrix no: 3
[(1.0, 2.0, 3.0), (5.0, 6.0, 7.0)]
[(8.0, 4.0, 3.0), (8.0, 6.0, 4.0)]
([(1.0, 2.0, 3.0), (5.0, 6.0, 7.0)], [(8.0, 4.0, 3.0), (8.0, 6.0, 4.0)])
Why I couldn't get the maximum value in tuples of the matrix in the above program? What should I do to get the maximum values in tuples of the matrix in the above program?
Suppose if I need the maximum value in tuples of the matrix 1 & 2, matrix 3 & 2, matrix 1 & 3 and matrix 1, 2 & 3. How to get the collection of all possible maximum matrices?
For example, I need the result to be
maximum value of tuples of matrix 1, 2 & 3
i.e.,
[(7.0, 7.0, 8.0), (6.0, 8.0, 8.0)]
[(9.0, 4.0, 6.0), (9.0, 6.0, 4.0)]
Likewise for matrix 1 & 2, matrix 3 & 2, matrix 1 & 3