The document contains examples of matrices represented numerically and in Python code. It shows a 3x4 numeric matrix, a 2x3 matrix defined in Python, and a 3x4 matrix with floating point entries defined in Python. It also includes a Python code sample that takes user input to build a matrix of any size and then prints the populated matrix.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
60 views2 pages
3 X 4 Matrix
The document contains examples of matrices represented numerically and in Python code. It shows a 3x4 numeric matrix, a 2x3 matrix defined in Python, and a 3x4 matrix with floating point entries defined in Python. It also includes a Python code sample that takes user input to build a matrix of any size and then prints the populated matrix.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
// 3 x 4 matrix
1234
M 4567
6789
// 2 x 3 matrix in Python
A = ( [ 2, 5, 7 ],
[ 4, 7, 9 ] )
// 3 x 4 matrix in Python where entries are floating numbers
B = ( [ 1.0, 3.5, 5.4, 7.9 ],
[ 9.0, 2.5, 4.2, 3.6 ],
[ 1.5, 3.2, 1.6, 6.5 ] )
# A basic code for matrix input from user
R = int(input("Enter the number of rows:"))
C = int(input("Enter the number of columns:"))
# Initialize matrix matrix = [] print("Enter the entries rowwise:")
# For user input
for i in range(R): # A for loop for row entries a =[] for j in range(C): # A for loop for column entries a.append(int(input())) matrix.append(a)
# For printing the matrix
for i in range(R): for j in range(C): print(matrix[i][j], end = " ") print() Output: Enter the number of rows:2 Enter the number of columns:3 Enter the entries rowwise: 1 2 3 4 5 6