Bird
0
0

What is the output of the following code?

medium📝 Predict Output Q4 of 15
SciPy - Linear Algebra (scipy.linalg)
What is the output of the following code?
import numpy as np
from scipy.linalg import norm
A = np.array([[3, 4], [0, 0]])
n = norm(A, ord=2)
A5.0
B4.0
C3.0
D7.0
Step-by-Step Solution
Solution:
  1. Step 1: Understand norm with ord=2

    Norm with ord=2 calculates the largest singular value (spectral norm) of matrix A.
  2. Step 2: Calculate norm of A

    Matrix A has rows [3,4] and [0,0]. The largest singular value equals the Euclidean norm of [3,4], which is sqrt(3^2 + 4^2) = 5.
  3. Final Answer:

    5.0 -> Option A
  4. Quick Check:

    Matrix spectral norm = 5.0 [OK]
Quick Trick: Norm with ord=2 gives largest singular value [OK]
Common Mistakes:
MISTAKES
  • Confusing norm with sum
  • Using wrong ord parameter
  • Calculating element-wise norm

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes