# How to make vector in Python

To create a vector in Python we use the array function of the numpy library.

**array(x)**

The argument x is a list containing the elements **[e _{1},e_{2},...,e_{n}]** of the vector.

This function allows vector calculations in Python.

**Example**

We import the numpy module into the python interpreter.

import numpy as np

We assign a vector to a variable with the function **array()**.

v=np.array([1,2,3,4,5])

It is a vector composed of five elements:

The content of the variable v is

array([1, 2, 3, 4, 5])

Now the variable v can be used to perform all operations on vectors and matrices of linear algebra. For example, the addition between vectors (v + v), the multiplication between vectors (v * v), in the product for a scalar (k * v), in the scalar product, etc.

**Report an error or share a suggestion to enhance this page**