Challenge - 5 Problems
Linear Algebra Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2: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)
Attempts:
2 left
💡 Hint
Remember matrix multiplication sums the products of rows and columns.
✗ Incorrect
Matrix multiplication multiplies rows of the first matrix by columns of the second. For example, element (0,0) is 1*2 + 2*1 = 4.
❓ data_output
intermediate1: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)
Attempts:
2 left
💡 Hint
Multiply corresponding elements and add them up.
✗ Incorrect
Dot product = 1*4 + 3*(-2) + (-5)*(-1) = 4 - 6 + 5 = 3.
❓ visualization
advanced3: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()
Attempts:
2 left
💡 Hint
Eigenvectors are directions; eigenvalues scale these directions.
✗ Incorrect
The quiver plot shows arrows from origin representing eigenvectors directions, colored differently, scaled by eigenvalues.
🧠 Conceptual
advanced1:30remaining
Why is matrix inversion important in data science?
Which option best explains why matrix inversion is important in data science?
Attempts:
2 left
💡 Hint
Think about solving equations like Ax = b.
✗ Incorrect
Matrix inversion allows solving equations by finding x = A^-1 b, crucial in regression and optimization tasks.
🔧 Debug
expert2: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)
Attempts:
2 left
💡 Hint
Check if the number of columns in A matches number of rows in B.
✗ Incorrect
Matrix multiplication requires inner dimensions to match. Here A is 2x3, B is 2x2, so 3 != 2 causes ValueError.