0
0
NumPydata~20 mins

Why linear algebra matters in NumPy - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Linear Algebra Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Matrix multiplication output
What is the output of the following code that multiplies two matrices using NumPy?
NumPy
import numpy as np
A = np.array([[1, 2], [3, 4]])
B = np.array([[2, 0], [1, 2]])
result = np.dot(A, B)
print(result)
A
[[2 0]
 [3 2]]
B
[[2 4]
 [3 8]]
C
[[1 2]
 [3 4]]
D
[[4 4]
 [10 8]]
Attempts:
2 left
💡 Hint
Remember matrix multiplication sums the products of rows and columns.
data_output
intermediate
1:30remaining
Vector dot product result
What is the result of the dot product between vectors a and b?
NumPy
import numpy as np
a = np.array([1, 3, -5])
b = np.array([4, -2, -1])
dot_product = np.dot(a, b)
print(dot_product)
A3
B-3
C0
D10
Attempts:
2 left
💡 Hint
Multiply corresponding elements and add them up.
visualization
advanced
3:00remaining
Visualizing eigenvectors and eigenvalues
Which plot correctly shows eigenvectors of matrix M scaled by their eigenvalues?
NumPy
import numpy as np
import matplotlib.pyplot as plt
M = np.array([[2, 1], [1, 2]])
eigenvalues, eigenvectors = np.linalg.eig(M)
origin = np.array([0, 0])
plt.quiver(*origin, eigenvalues * eigenvectors[0, :], eigenvalues * eigenvectors[1, :], angles='xy', scale_units='xy', scale=1, color=['r','b'])
plt.xlim(-2, 2)
plt.ylim(-2, 2)
plt.grid()
plt.show()
ARed and blue arrows from origin showing directions of eigenvectors scaled by eigenvalues
BScatter plot of random points unrelated to eigenvectors
CBar chart of eigenvalues only
DLine plot of eigenvalues over index
Attempts:
2 left
💡 Hint
Eigenvectors are directions; eigenvalues scale these directions.
🧠 Conceptual
advanced
1:30remaining
Why is matrix inversion important in data science?
Which option best explains why matrix inversion is important in data science?
AIt is used to multiply matrices faster than normal multiplication.
BIt helps solve systems of linear equations, which is key in regression and optimization.
CIt converts matrices into vectors for easier analysis.
DIt removes noise from data by filtering matrix elements.
Attempts:
2 left
💡 Hint
Think about solving equations like Ax = b.
🔧 Debug
expert
2:00remaining
Identify the error in matrix multiplication code
What error does the following code raise?
NumPy
import numpy as np
A = np.array([[1, 2, 3], [4, 5, 6]])
B = np.array([[7, 8], [9, 10]])
result = np.dot(A, B)
print(result)
ATypeError: unsupported operand type(s) for *: 'int' and 'list'
BIndexError: index out of bounds
CValueError: shapes (2,3) and (2,2) not aligned: 3 (dim 1) != 2 (dim 0)
DNo error, prints a 2x2 matrix
Attempts:
2 left
💡 Hint
Check if the number of columns in A matches number of rows in B.