In Python, a matrix is a multi-dimensional array that is used to store and manipulate numerical values. Matrices are widely used in various mathematical and scientific applications, including linear algebra, computer graphics, and image processing. Matrices can be represented as two-dimensional arrays in Python, where each element is represented by a row and a column. Matrices can be easily created, manipulated, and transformed using various built-in functions and libraries in Python, making it an essential tool for data analysis and scientific computing. In Python, a matrix can be represented as a 2-dimensional list. A matrix in Python is a data structure that represents a table of elements, where each element can be a number, string, or any other object. It is a 2-dimensional arrangement of rows and columns, similar to a spreadsheet or a table in a database. A matrix can be represented in Python using a list of lists. For example:
Output:-
The Main Python program to find Matrix of either 2*2 format or 3*3 format with using if-else statement given below :-
OUTPUT:-