Calling Column of a Matrix | Linear Algebra using Python

Linear Algebra using Python | Calling Column of a Matrix: Here, we are going to learn how to call columns of a matrix in Python?
Submitted by Anuj Singh, on May 14, 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. Columns are the heart of a Matrix. From column space to null space of a matrix is based on Columns. Therefore, whenever we have to go for Column operations, then we have to call our columns.

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

Python code for calling column of a matrix

# Linear Algebra Learning Sequence
# Calling Column of 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)

j = int(input("Enter j (column number) : "))

# Printing the V[i][j] element of the matrix
ln = len(V)
for i in range(ln):
    print("Component [",i,"] [",j,"] :", V[i][j-1])   

Output:

--The Matrix-- 
 [[  1   2   3]
 [  2   3   5]
 [  3   6   8]
 [323 623 823]]
Enter j (column number) : 2
Component [ 0 ] [ 2 ] : 2
Component [ 1 ] [ 2 ] : 3
Component [ 2 ] [ 2 ] : 6
Component [ 3 ] [ 2 ] : 623





Comments and Discussions

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





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.