0
0
SciPydata~10 mins

Frequency array generation (fftfreq) in SciPy - 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 fftfreq function from scipy.fft module.

SciPy
from scipy.fft import [1]
Drag options to blanks, or click blank then click option'
Afft
Bfftshift
Cifft
Dfftfreq
Attempts:
3 left
💡 Hint
Common Mistakes
Importing 'fft' instead of 'fftfreq'.
Using 'ifft' which is inverse FFT.
Importing 'fftshift' which shifts zero frequency.
2fill in blank
medium

Complete the code to generate frequency bins for a signal of length 8.

SciPy
freqs = fftfreq([1])
Drag options to blanks, or click blank then click option'
A8
B16
C4
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number larger or smaller than the signal length.
Confusing frequency bins count with sampling rate.
3fill in blank
hard

Fix the error in the code to generate frequency bins with a sample spacing of 0.5 seconds.

SciPy
freqs = fftfreq(10, [1]=0.5)
Drag options to blanks, or click blank then click option'
Ad
Bdt
Cspacing
Dsample_spacing
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'dt' or 'spacing' which are not valid parameter names.
Passing sample spacing as a positional argument instead of keyword.
4fill in blank
hard

Fill both blanks to create a frequency array for 12 samples with sample spacing 0.1 seconds.

SciPy
freqs = fftfreq([1], [2]=0.1)
Drag options to blanks, or click blank then click option'
A12
B10
Cd
Ddt
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong parameter name for sample spacing.
Using incorrect number of samples.
5fill in blank
hard

Fill all three blanks to create a dictionary mapping frequencies to their indices for 6 samples with spacing 0.2 seconds, including only positive frequencies.

SciPy
freqs = fftfreq([1], [2]=0.2)
positive_freqs = {i: f for i, f in enumerate(freqs) if f [3] 0}
Drag options to blanks, or click blank then click option'
A6
Bd
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operator to filter frequencies.
Using incorrect parameter name for sample spacing.
Using wrong number of samples.