Examples :
// 3 x 4 matrix 1 2 3 4 M = 4 5 6 7 6 7 8 9 / / 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])
input. Some of the methods for the user input matrix in Python are shown below:
Code # 1:
# Base matrix input code from user
R
=
int
(
input
(
"Enter the number of rows:"
))
C
=
int
(
input
(
" Enter the number of columns: "
))
# Initializers set 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 to write this in columns
a.append (
int
(
input
()))
matrix.append (a)
# To print 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 1 2 3 4 5 6
One liner:

Code # 2: Using map ()
and Numpy
.
Python has a popular library NumPy . This library is a fundamental library for any scientific calculations. It is also used for multidimensional arrays, and since we know the matrix — this is a rectangular array, we will use this library for the user input matrix.

Exit:
Enter the number of rows: 2 Enter the number of columns: 2 Enter the entries in a single line separated by space: 1 2 3 1 [[1 2] [3 1]]
The genesis of this book began in 2012. Hadoop was being explored in mainstream organizations, and we believed that information architecture was about to be transformed. For many years, business intel...
10/07/2020
Python Data Science Handbook: Essential Tools for Working with Data  PDF, 1st Edition For many researchers, Python is a firstclass tool, primarily because of its libraries for storing, manipulati...
22/08/2021
Managing and analyzing data have always offered the greatest benefits and the greatest challenges for organizations of all sizes and across all industries. Businesses have long struggled with finding ...
10/07/2020
In Learn Python 3 the Hard Way PDF, you'll learn Python by working through 52 brilliantly crafted exercises. Read them. Enter your code exactly. (No copying and pasting!) Correct your mistakes. ...
05/09/2021