Q:

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

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

Sample Output:

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now