Challenge - 5 Problems
SciPy Module Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2: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))]))
Attempts:
2 left
💡 Hint
Think about the current main submodules in SciPy 1.10+ where fftpack was replaced by fft.
✗ Incorrect
SciPy reorganized its FFT functionality from 'fftpack' to 'fft' in recent versions. The main submodules include 'cluster', 'constants', 'fft', 'integrate', 'interpolate', 'io', 'linalg', 'ndimage', 'optimize', 'signal', 'sparse', 'spatial', 'special', and 'stats'. 'random' is a submodule of 'scipy.stats' and not a top-level submodule.
🧠 Conceptual
intermediate1:30remaining
Purpose of SciPy submodules
Which SciPy submodule is primarily used for numerical integration and solving differential equations?
Attempts:
2 left
💡 Hint
Think about the submodule that deals with calculating areas under curves and solving ODEs.
✗ Incorrect
The 'scipy.integrate' submodule provides functions for numerical integration and solving ordinary differential equations (ODEs). 'optimize' is for optimization, 'linalg' for linear algebra, and 'signal' for signal processing.
🔧 Debug
advanced2: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]))
Attempts:
2 left
💡 Hint
Check if 'fftpack' is still a direct submodule of SciPy in recent versions.
✗ Incorrect
In recent SciPy versions, 'fftpack' was replaced by 'fft'. The 'scipy' module no longer has 'fftpack', so 'from scipy import fftpack' raises ImportError: cannot import name 'fftpack' from 'scipy'.
❓ data_output
advanced1: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)
Attempts:
2 left
💡 Hint
The shape of a matrix is (rows, columns).
✗ Incorrect
The input list has 3 rows and 3 columns, so the sparse matrix shape is (3, 3).
🚀 Application
expert2: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?
Attempts:
2 left
💡 Hint
Statistical tests are usually found in the submodule dedicated to statistics.
✗ Incorrect
The 'scipy.stats' submodule contains many statistical functions including t-tests. 'optimize' is for optimization, 'linalg' for linear algebra, and 'signal' for signal processing.