NumPy Exercises

NumPy: Get the magnitude of a vector in numpy

NumPy: Array Object Exercise-93 with Solution

Write a NumPy program to get the magnitude of a vector in numpy.

Sample Solution:-

Python Code:

import numpy as np
x = np.array([1,2,3,4,5])
print("Original array:")
print("Magnitude of the vector:")

Sample Output:

Original array:                                                        
[1 2 3 4 5]                                                            
Magnitude of the vector:                                               

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a NumPy program to select indices satisfying multiple conditions in a numpy array.
Next: Write a NumPy program to count the frequency of unique values in numpy array.

What is the difficulty level of this exercise?

New Content: Composer: Dependency manager for PHP, R Programming