Calling ith dimensional Component of Vector | Linear Algebra using Python

Linear Algebra using Python: In this article, we will learn about calling ith dimensional component of Vector, python implementation of it.
Submitted by Anuj Singh, on May 12, 2020

Prerequisite: Linear Algebra | Defining a Vector

Linear algebra is the branch of mathematics concerning linear equations by using vector spaces and through matrices. In other words, a vector is a matrix in n-dimensional space with only one column. In the sequence of learning linear algebra using python, this is article 4. In some of the problems, we need to use a particular component of the vector.

For example: Let a vector a = [4, 9, 7], this is a 3 dimensional vector (x,y and z)

So, if we need to call the yth component of the vector, we are talking about the corresponding value 9. 

In the python code, we will first define a vector and then we will call its 4th component.

Python code for calling ith dimensional Component of Vector

# Vectors in Linear Algebra
a = [3, 5, -5, 8]

print("Vector a = ", a)
# This is a 4-dimensional vector

i = int(input("type dimensional component you want to know: "))
print("Vector's", i," dimensional component = ", a[i-1])

Output

Vector a =  [3, 5, -5, 8]
type dimensional component you want to know: 4
Vector's 4  dimensional component =  8


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.