Home » Python » Linear Algebra using Python

# Row numbers in a Matrix | Linear Algebra using Python

**Linear Algebra using Python | Row numbers in a Matrix**: Here, we are going to learn how to get row numbers in a matrix in Python?

Submitted by Anuj Singh, on May 20, 2020

Linear algebra is the branch of mathematics concerning linear equations by using vector spaces and through matrices. Matrix is the key to linear algebra. All the linear algebra revolves around matrices. For many operations with a Matrix, we need to know about the number **of rows in a matrix**.

In python, we can find it using two methods. One of the simplest methods we are going to see is just using the *len(M)* function. Python considers the length of a Matrix as the number of rows in it.

Rows also have a different interpretation as row space. So whenever we are asked to find the number of dimensions in the row space of a matrix, we can just put the inbuilt function **len(M)** in our code to answer such questions.

The following code shows how to call a whole row of a matrix.

## Python code for Row numbers in a Matrix

# Linear Algebra Learning Sequence # Row numbers in a Matrix import numpy as np # Use of np.array() to define a matrix V = np.array([[1,2,3],[2,3,5],[3,6,8],[323,623,823]]) print("--The Matrix-- \n",V) #number of rows num = len(V) print("Number of rows in the Given Matrix : ", num)

**Output:**

--The Matrix-- [[ 1 2 3] [ 2 3 5] [ 3 6 8] [323 623 823]] Number of rows in the Given Matrix : 4

TOP Interview Coding Problems/Challenges

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions

**Ad:**
Are you a blogger? Join our Blogging forum.