Complete the code to import the function for computing the Discrete Fourier Transform.
from numpy.fft import [1]
The fft function computes the Discrete Fourier Transform of a signal.
Complete the code to compute the DFT of the signal array named signal.
dft_result = [1](signal)The np.fft.fft function computes the DFT of the input signal.
Fix the error in the code to correctly compute the magnitude spectrum of the DFT result.
magnitude = abs([1])The magnitude spectrum is the absolute value of the DFT result, so we first compute np.fft.fft(signal) and then take its absolute value.
Fill both blanks to create a dictionary comprehension that maps each frequency bin index to its magnitude if magnitude is greater than 10.
freq_magnitudes = {i: magnitudes[i] for i in range(len(magnitudes)) if magnitudes[i] [1] [2]The comprehension filters frequency bins where magnitude is greater than 10 using > and 10.
Fill all three blanks to create a dictionary comprehension that maps frequency bin indices (starting from 0) to their magnitude only if magnitude is greater than 5 and less than 20.
filtered_magnitudes = {i: magnitudes[i] for i in range([1]) if magnitudes[i] [2] 5 and magnitudes[i] [3] 20}The comprehension iterates over all indices from 0 to len(magnitudes) and filters magnitudes greater than 5 and less than 20. Here, the blanks are filled with the range length, the greater than operator, and the less than operator respectively.
