Complete the code to import the Fourier transform function from scipy.
from scipy.fft import [1]
The fft function computes the Fast Fourier Transform, which reveals frequency components.
Complete the code to create a time array from 0 to 1 second with 500 points.
import numpy as np time = np.linspace(0, [1], 500)
The time array should span 1 second, so the end value is 1.
Fix the error in the code to generate a signal with frequency 5 Hz.
freq = 5 signal = np.sin(2 * np.pi * freq * [1])
The signal depends on time, so the variable time must be used inside the sine function.
Fill both blanks to compute the Fourier transform and get the frequency bins.
yf = [1](signal) xf = np.fft.fftfreq(len(signal), [2])
fft computes the Fourier transform. The second blank is the sample spacing, which is 1/500 = 0.002 seconds.
Fill both blanks to create a dictionary of frequencies and their amplitudes above a threshold.
result = {xf[1]: abs(yf) for i, yf in enumerate(yf) if abs(yf) [2] 10}The frequency at index i is xf[i]. The amplitude is abs(yf). We filter amplitudes greater than 10.