Complete the code to calculate the Fourier Transform of a signal array named 'signal'.
import numpy as np signal = np.array([1, 2, 3, 4, 5]) transformed_signal = np.fft.[1](signal)
The np.fft.fft function computes the Fourier Transform, which converts the signal from time domain to frequency domain.
Complete the code to compute the magnitude spectrum of the Fourier Transform stored in 'transformed_signal'.
magnitude = np.[1](transformed_signal)The magnitude spectrum is obtained by taking the absolute value of the complex Fourier Transform result using np.abs.
Fix the error in the code to filter a signal using convolution with a kernel named 'filter_kernel'.
filtered_signal = np.convolve(signal, [1], mode='same')
The convolution should be done between the original signal and the filter kernel, so the second argument must be filter_kernel.
Fill both blanks to create a dictionary comprehension that maps each frequency to its magnitude if magnitude is greater than 10.
freq_magnitude = {freq: mag for freq, mag in zip(frequencies, magnitudes) if mag [1] 10 and freq [2] 0}The comprehension filters magnitudes greater than 10 and frequencies not equal to zero.
Fill all three blanks to create a dictionary comprehension that maps the uppercase frequency label to its magnitude if magnitude is less than 50.
result = { [1]: [2] for [3] in zip(freq_labels, magnitudes) if mag < 50 }The comprehension uses label.upper() as key, mag as value, and iterates over label and mag from zipped lists.
