0
0
SciPydata~10 mins

Matrix determinant (det) in SciPy - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the function that calculates the determinant of a matrix.

SciPy
from scipy.linalg import [1]

matrix = [[1, 2], [3, 4]]
result = det(matrix)
print(result)
Drag options to blanks, or click blank then click option'
Adet
Bdeterminant
Cdetermin
Ddeterminant_calc
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong function name like 'determinant' which does not exist in scipy.linalg.
Trying to import from numpy.linalg instead of scipy.linalg.
2fill in blank
medium

Complete the code to calculate the determinant of the given matrix.

SciPy
from scipy.linalg import det

matrix = [[2, 3], [1, 4]]
determinant = [1](matrix)
print(determinant)
Drag options to blanks, or click blank then click option'
Adet_calc
Bdet
Cdetermin
Ddeterminant
Attempts:
3 left
💡 Hint
Common Mistakes
Calling a function that is not imported or does not exist.
Trying to call 'determinant' which is not defined.
3fill in blank
hard

Fix the error in the code to correctly compute the determinant of the matrix.

SciPy
from scipy.linalg import det

matrix = [[1, 2, 3], [4, 5, 6]]
det_value = [1](matrix)
print(det_value)
Drag options to blanks, or click blank then click option'
Adetermin
Bdeterminant
Cdet_calc
Ddet
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong function name.
Trying to calculate determinant of a non-square matrix (which causes runtime error).
4fill in blank
hard

Fill both blanks to create a dictionary of determinants for matrices with size 2 and 3.

SciPy
from scipy.linalg import det

matrices = {
    2: [[1, 2], [3, 4]],
    3: [[1, 0, 2], [0, 1, 5], [3, 2, 1]]
}
determinants = {size: det([1]) for size, [2] in matrices.items()}
print(determinants)
Drag options to blanks, or click blank then click option'
Amatrix
Bmat
Cmatrixes
Dm
Attempts:
3 left
💡 Hint
Common Mistakes
Using the key instead of the value for determinant calculation.
Using variable names not matching the iteration unpacking.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that stores determinants of matrices with keys as uppercase size names.

SciPy
from scipy.linalg import det

matrices = {
    'two': [[2, 0], [0, 2]],
    'three': [[1, 2, 3], [0, 1, 4], [5, 6, 0]]
}
determinants = [1]([2].upper(): [3](matrix) for [2], matrix in matrices.items())
print(determinants)
Drag options to blanks, or click blank then click option'
Adict
Bkey
Cdet
Dvalue
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same variable name for both key and value in the comprehension.
Not converting the key to uppercase.
Using a wrong function name for determinant.