Challenge - 5 Problems
FFT Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of FFT on a simple signal
What is the output of the following code that computes the FFT of a simple signal?
SciPy
import numpy as np from scipy.fft import fft signal = np.array([1, 0, 1, 0]) result = fft(signal) print(result)
Attempts:
2 left
💡 Hint
Recall that FFT output length matches input and sums frequency components.
✗ Incorrect
The FFT of [1,0,1,0] results in [2,0,2,0] in complex form, representing frequency components.
❓ data_output
intermediate1:30remaining
Length of FFT output array
Given a real input array of length 8, what is the length of the output array from scipy.fft.fft?
SciPy
import numpy as np from scipy.fft import fft x = np.arange(8) y = fft(x) print(len(y))
Attempts:
2 left
💡 Hint
FFT output length equals input length for scipy.fft.fft.
✗ Incorrect
The FFT output array length is the same as the input array length for scipy.fft.fft.
🔧 Debug
advanced1:30remaining
Identify the error in FFT usage
What error does this code raise when trying to compute FFT on a list of strings?
SciPy
from scipy.fft import fft signal = ['1', '0', '1', '0'] result = fft(signal)
Attempts:
2 left
💡 Hint
FFT expects numeric input, not strings.
✗ Incorrect
Passing a list of strings to fft causes a TypeError because FFT operations require numeric types.
🚀 Application
advanced2:30remaining
Using FFT to find dominant frequency
Given a sampled signal with 1000 points and sampling rate 1000 Hz, which code snippet correctly finds the frequency with the highest amplitude?
SciPy
import numpy as np from scipy.fft import fft, fftfreq sampling_rate = 1000 N = 1000 x = np.linspace(0, 1, N, endpoint=False) signal = np.sin(2*np.pi*50*x) + 0.5*np.sin(2*np.pi*120*x) # Find dominant frequency code here
Attempts:
2 left
💡 Hint
Use fftfreq with correct sample spacing and find index of max amplitude.
✗ Incorrect
The dominant frequency corresponds to the index of the maximum absolute FFT value. fftfreq needs sample spacing 1/sampling_rate.
🧠 Conceptual
expert2:00remaining
Understanding FFT symmetry for real inputs
For a real-valued input signal of length N, which statement about the FFT output is true?
Attempts:
2 left
💡 Hint
Think about conjugate symmetry property of FFT for real signals.
✗ Incorrect
For real inputs, FFT output has Hermitian symmetry: second half is complex conjugate of first half reversed.