0
0
SciPydata~20 mins

SciPy module organization - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SciPy Module Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Understanding SciPy submodules
What will be the output of this code snippet that lists the main submodules of SciPy?
SciPy
import scipy
print(sorted([sub for sub in dir(scipy) if not sub.startswith('_') and isinstance(getattr(scipy, sub), type(scipy))]))
A['cluster', 'constants', 'fftpack', 'integrate', 'interpolate', 'io', 'linalg', 'ndimage', 'optimize', 'signal', 'sparse', 'spatial', 'special', 'stats', 'random']
B['cluster', 'constants', 'fftpack', 'integrate', 'interpolate', 'io', 'linalg', 'ndimage', 'optimize', 'signal', 'sparse', 'spatial', 'special', 'stats']
C['cluster', 'constants', 'fft', 'integrate', 'interpolate', 'io', 'linalg', 'ndimage', 'optimize', 'signal', 'sparse', 'spatial', 'special']
D['cluster', 'constants', 'fft', 'integrate', 'interpolate', 'io', 'linalg', 'ndimage', 'optimize', 'signal', 'sparse', 'spatial', 'special', 'stats']
Attempts:
2 left
💡 Hint
Think about the current main submodules in SciPy 1.10+ where fftpack was replaced by fft.
🧠 Conceptual
intermediate
1:30remaining
Purpose of SciPy submodules
Which SciPy submodule is primarily used for numerical integration and solving differential equations?
Ascipy.signal
Bscipy.integrate
Cscipy.linalg
Dscipy.optimize
Attempts:
2 left
💡 Hint
Think about the submodule that deals with calculating areas under curves and solving ODEs.
🔧 Debug
advanced
2:00remaining
Identifying error in SciPy submodule import
What error will this code raise and why? import scipy from scipy import fftpack print(fftpack.fft([1, 2, 3, 4]))
AImportError: cannot import name 'fftpack' from 'scipy'
BAttributeError: module 'scipy' has no attribute 'fftpack'
CTypeError: 'list' object is not callable
DNo error, prints the FFT result
Attempts:
2 left
💡 Hint
Check if 'fftpack' is still a direct submodule of SciPy in recent versions.
data_output
advanced
1:30remaining
Output of SciPy sparse matrix shape
What is the output of this code snippet?
SciPy
from scipy import sparse
matrix = sparse.csr_matrix([[0, 0, 1], [1, 0, 0], [0, 0, 0]])
print(matrix.shape)
A(1, 3)
B(3, 1)
C(3, 3)
D(0, 0)
Attempts:
2 left
💡 Hint
The shape of a matrix is (rows, columns).
🚀 Application
expert
2:00remaining
Choosing the correct SciPy submodule for statistical tests
You want to perform a t-test to compare the means of two independent samples. Which SciPy submodule should you use?
Ascipy.stats
Bscipy.signal
Cscipy.linalg
Dscipy.optimize
Attempts:
2 left
💡 Hint
Statistical tests are usually found in the submodule dedicated to statistics.