Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the 'integrate' submodule from SciPy.
SciPy
from scipy import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong submodule like 'optimize' or 'stats'.
Using 'import scipy.integrate' instead of 'from scipy import integrate'.
✗ Incorrect
The 'integrate' submodule is imported from SciPy using 'from scipy import integrate'.
2fill in blank
mediumComplete the code to import the 'optimize' submodule from SciPy.
SciPy
import scipy.[1] as opt
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'import scipy.integrate as opt' which is incorrect aliasing.
Forgetting the alias 'as opt' after the import.
✗ Incorrect
The 'optimize' submodule is imported as 'opt' using 'import scipy.optimize as opt'.
3fill in blank
hardFix the error in the code to correctly import the 'stats' submodule from SciPy.
SciPy
from scipy import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'stat' or 'statistics' which do not exist as SciPy submodules.
Misspelling the submodule name.
✗ Incorrect
The correct submodule name is 'stats', not 'stat' or other variants.
4fill in blank
hardFill both blanks to import 'linalg' submodule and use its 'inv' function to compute the inverse of matrix 'A'.
SciPy
from scipy import [1] result = [2].inv(A)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing wrong submodule like 'integrate' or 'optimize'.
Using wrong alias or submodule name when calling 'inv'.
✗ Incorrect
The 'linalg' submodule is imported and used to call 'inv' for matrix inversion.
5fill in blank
hardFill all three blanks to import 'signal' submodule, create a simple sine wave, and apply a low-pass filter using 'butter' and 'filtfilt'.
SciPy
import numpy as np from scipy import [1] fs = 500 # Sampling frequency T = 1.0 # seconds n = int(T * fs) t = np.linspace(0, T, n, endpoint=False) x = np.sin(2 * np.pi * 5 * t) b, a = [2].butter(4, 0.1, 'low') y = [3].filtfilt(b, a, x)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing wrong submodule like 'integrate'.
Using different submodule names when calling 'butter' or 'filtfilt'.
✗ Incorrect
The 'signal' submodule is imported and used to create a Butterworth filter and apply it with 'filtfilt'.