0
0
SciPydata~10 mins

Importing SciPy submodules - 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 'integrate' submodule from SciPy.

SciPy
from scipy import [1]
Drag options to blanks, or click blank then click option'
Aoptimize
Bintegrate
Cstats
Dcluster
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong submodule like 'optimize' or 'stats'.
Using 'import scipy.integrate' instead of 'from scipy import integrate'.
2fill in blank
medium

Complete 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'
Asignal
Bintegrate
Clinalg
Doptimize
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'import scipy.integrate as opt' which is incorrect aliasing.
Forgetting the alias 'as opt' after the import.
3fill in blank
hard

Fix 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'
Astat
Bstatistic
Cstats
Dstatistics
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'stat' or 'statistics' which do not exist as SciPy submodules.
Misspelling the submodule name.
4fill in blank
hard

Fill 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'
Alinalg
Bintegrate
Doptimize
Attempts:
3 left
💡 Hint
Common Mistakes
Importing wrong submodule like 'integrate' or 'optimize'.
Using wrong alias or submodule name when calling 'inv'.
5fill in blank
hard

Fill 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'
Asignal
Dintegrate
Attempts:
3 left
💡 Hint
Common Mistakes
Importing wrong submodule like 'integrate'.
Using different submodule names when calling 'butter' or 'filtfilt'.