0
0
SciPydata~10 mins

Why linear algebra is the foundation of scientific computing in SciPy - Test Your Understanding

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

Complete the code to create a 2x2 matrix using NumPy.

SciPy
import numpy as np
matrix = np.array([1])
Drag options to blanks, or click blank then click option'
A[[1, 2], [3, 4]]
B[1, 2, 3, 4]
C[[1, 2, 3], [4, 5, 6]]
D[1, 2]
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a flat list instead of a list of lists.
Creating a matrix with wrong dimensions.
2fill in blank
medium

Complete the code to compute the dot product of two vectors using NumPy.

SciPy
import numpy as np
v1 = np.array([1, 2, 3])
v2 = np.array([4, 5, 6])
dot_product = np.[1](v1, v2)
Drag options to blanks, or click blank then click option'
Amultiply
Bdot
Ccross
Dsum
Attempts:
3 left
💡 Hint
Common Mistakes
Using multiply which returns element-wise multiplication.
Using cross which computes the cross product.
3fill in blank
hard

Fix the error in the code to compute the inverse of a matrix using SciPy.

SciPy
from scipy import linalg
import numpy as np
matrix = np.array([[1, 2], [3, 4]])
inverse = linalg.[1](matrix)
Drag options to blanks, or click blank then click option'
Ainverse
Binvert
Cinversed
Dinv
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent functions like inverse or invert.
Misspelling the function name.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each word to its length only if the length is greater than 3.

SciPy
words = ['data', 'science', 'is', 'fun']
lengths = {word: [1] for word in words if [2]
Drag options to blanks, or click blank then click option'
Alen(word)
Bword
Clen(word) > 3
Dword > 3
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself instead of its length as the value.
Comparing the word string directly to a number.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps each uppercase word to its length only if the length is greater than 2.

SciPy
words = ['AI', 'ML', 'Data', 'Code']
result = { [1]: [2] for word in words if [3] }
Drag options to blanks, or click blank then click option'
Aword.upper()
Blen(word)
Clen(word) > 2
Dword.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using word.lower() instead of uppercase.
Not filtering words by length correctly.