NumPy: Find the number of rows and columns of a given matrix
NumPy: Basic Exercise-26 with Solution
Write a NumPy program to find the number of rows and columns of a given matrix.
Sample Solution :
Python Code :
import numpy as np m= np.arange(10,22).reshape((3, 4)) print("Original matrix:") print(m) print("Number of rows and columns of the said matrix:") print(m.shape)
Original matrix: [[10 11 12 13] [14 15 16 17] [18 19 20 21]] Number of rows and columns of the said matrix: (3, 4)
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
- New Content published on w3resource :
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework