Program to get the magnitude of a NumPy vector

In this python numpy program, we will get the magnitude of a NumPy vector.

Steps to solve the program
  1. Import the numpy library as np.
  2. Create a vector using np.array().
  3. Get the magnitude of the vector using np.linalg.norm().
  4. Print the output.
				
					import numpy as np
x = np.array([3, 5, 1])

print("Magnitude of the given vector: ",np.linalg.norm(x))
				
			

Output :

				
					Magnitude of the given vector:  5.916079783099616
				
			

remove all rows in a NumPy array that contain non-numeric values.

count the frequency of unique values.

Leave a Comment