Home » Python » Linear Algebra using Python

# Defining Vector using Numpy | Linear Algebra using Python

**Linear Algebra using Python | Defining Vector using Numpy**: Here, we are going to learn how to define vector using numpy in Python?

Submitted by Anuj Singh, on May 17, 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 previous tutorials, we defined the vector using the list. Defining a vector using a list is very fine and easy but it has some limitations. We can only define vectors through lists when there is only vector manipulation involved. As matrices are involved, then we have to define a vector using A supremely-optimized, well-maintained scientific computing package for Python called numpy.

Let's see how we can define a vector using this library:

## Python code for Defining Vector using Numpy

# Linear Algebra Learning Sequence # Defining a vector using numpy import numpy as np # Use of np.array() to define a vector V1 = np.array([[1],[2],[3]]) V2 = np.array([[14],[23],[35],[56],[754],[123]]) # printing vectors print("The Vector V1 = ",V1) print("The Vector V2 = ",V2)

**Output:**

The Vector V1 = [[1] [2] [3]] The Vector V2 = [[ 14] [ 23] [ 35] [ 56] [754] [123]]

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.