Home »
Python
Defining a Vector | Linear Algebra with Python
Linear Algebra with Python | Here, we are going to learn how to define a vector in Python?
Submitted by Anuj Singh, on May 10, 2020
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. So vector is one of the important constituents for linear algebra. In this tutorial, we will just understand how to represent a vector in python.
In the python code, we printed a random vector and it could be done by using the list of python. Secondly, we defined and printed a zero vector in 4-dimensional space. A zero vector is always denoted by z in linear algebra.
Python code to define a vector
# Vector in Linear Algebra
a = [3, 5, -5, 8]
# This is a 4 dimensional vector
# a list in python is a vector in linear algebra
print("Vector a = ", a)
# This is how we can print a vector in python
z = [0, 0, 0, 0]
print("Zero Vector z = ", z)
# This is a zero vector
Output
Vector a = [3, 5, -5, 8]
Zero Vector z = [0, 0, 0, 0]