0
0
NumPydata~20 mins

np.linalg.det() for determinant in NumPy - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Determinant Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Calculate determinant of a 2x2 matrix
What is the output of this code that calculates the determinant of a 2x2 matrix using np.linalg.det()?
NumPy
import numpy as np
matrix = np.array([[4, 7], [2, 6]])
det = np.linalg.det(matrix)
print(round(det, 2))
A0.0
B26.0
C1.0
D10.0
Attempts:
2 left
💡 Hint
Recall the formula for determinant of 2x2 matrix [[a, b], [c, d]] is ad - bc.
data_output
intermediate
2:00remaining
Determinant of a singular matrix
What is the value of det after running this code for a singular matrix?
NumPy
import numpy as np
matrix = np.array([[1, 2], [2, 4]])
det = np.linalg.det(matrix)
print(det)
A0.0
B2.0
C1.0
D-2.0
Attempts:
2 left
💡 Hint
A singular matrix has determinant zero.
🔧 Debug
advanced
2:00remaining
Identify the error in determinant calculation
What error does this code raise when trying to calculate the determinant?
NumPy
import numpy as np
matrix = np.array([1, 2, 3, 4])
det = np.linalg.det(matrix)
print(det)
AValueError: could not broadcast input array from shape (4,) into shape (2,2)
BTypeError: unsupported operand type(s) for -: 'int' and 'str'
CLinAlgError: Last 2 dimensions of the array must be square
DNo error, prints 0.0
Attempts:
2 left
💡 Hint
Check the shape of the input array for determinant calculation.
🚀 Application
advanced
2:00remaining
Using determinant to check matrix invertibility
Which option correctly checks if a matrix is invertible using its determinant?
NumPy
import numpy as np
matrix = np.array([[3, 1], [2, 4]])
det = np.linalg.det(matrix)
# Check invertibility here
A
if det > 0:
    print('Invertible')
else:
    print('Not invertible')
B
if det != 0:
    print('Invertible')
else:
    print('Not invertible')
C
if det == 1:
    print('Invertible')
else:
    print('Not invertible')
D
if det < 0:
    print('Invertible')
else:
    print('Not invertible')
Attempts:
2 left
💡 Hint
A matrix is invertible if its determinant is not zero.
🧠 Conceptual
expert
2:00remaining
Effect of row operations on determinant
If you multiply one row of a square matrix by 3, how does the determinant change?
AThe determinant is multiplied by 3
BThe determinant remains the same
CThe determinant is multiplied by 9
DThe determinant becomes zero
Attempts:
2 left
💡 Hint
Think about how scaling a row affects volume represented by determinant.