Responsive Navbar with Google Search
☰ Menu
Home
Python
LaTeX
GNUPlot
Arduino
Feedback
Contact Us
Matrix Operation: Matrix
Matrix Operation
Matrix
Matrix Addition
Matrix Multiplication
Matrix Transpose
Matrix Determinant
Matrix using List Comprehension
Matrix: Program 1
'''Define 2x2 matrix''' matrix = [ [1, 2], [3, 4] ] print(matrix)
Run Code
Output 1
Matrix: Program 2
'''Define 3x3 matrix''' matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] print(matrix)
Run Code
Output 2
Matrix: Program 3
'''Accessing Elements in a Matrix''' matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] element = matrix[1][2] # Access element in the 2nd row, 3rd column (zero-indexed) print(element)
Run Code
Output 3
Matrix: Program 4
'''Iterate over a matrix''' matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] for row in matrix: for element in row: print(element, end=" ") print()
Run Code
Output 4
Matrix: Program 5
'''Modify element in matrix''' matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] matrix[0][1] = 10 # Modify the element in the 1st row, 2nd column print(matrix)
Run Code
Output 5