हम पहले एक numpy मैट्रिक्स बनाएंगे और फिर उस मैट्रिक्स में पंक्तियों और स्तंभों की संख्या ढूंढेंगे।
एल्गोरिदम
चरण 1: रैंडम संख्याओं का numpy मैट्रिक्स बनाएं। चरण 2: numpy.shape फ़ंक्शन का उपयोग करके मैट्रिक्स की पंक्तियों और स्तंभों को ढूंढें। चरण 3: पंक्तियों और स्तंभों की संख्या प्रिंट करें।
उदाहरण कोड
import numpy as np
matrix = np.random.rand(2, 3)
print(matrix)
print("Total number of rows and columns in the given matrix are: ", matrix.shape)
आउटपुट
[[0.23226052 0.89690884 0.19813164] [0.85170808 0.97725669 0.72454096]] Total number of rows and columns in the given matrix are: (2, 3)