0
0
NumPydata~10 mins

FFT with np.fft module in NumPy - 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 FFT function from numpy's fft module.

NumPy
from numpy.fft import [1]

signal = [1, 2, 3, 4]
fft_result = [1](signal)
Drag options to blanks, or click blank then click option'
Aifft
Bfftshift
Cfft
Drfft
Attempts:
3 left
💡 Hint
Common Mistakes
Using ifft which computes the inverse FFT.
Using fftshift which shifts zero frequency component.
Using rfft which is for real input FFT.
2fill in blank
medium

Complete the code to compute the inverse FFT of a frequency domain signal.

NumPy
import numpy as np
freq_signal = np.array([10+0j, -2+2j, -2+0j, -2-2j])
time_signal = np.[1](freq_signal)
Drag options to blanks, or click blank then click option'
Aifft
Brfft
Cfft
Dirfft
Attempts:
3 left
💡 Hint
Common Mistakes
Using fft which computes forward FFT.
Using rfft which is for real input FFT.
Using irfft which is inverse FFT for real input only.
3fill in blank
hard

Fix the error in the code to compute the FFT of a signal using numpy.

NumPy
import numpy as np
signal = [1, 2, 3, 4]
fft_result = np.fft.[1](signal)
Drag options to blanks, or click blank then click option'
Afftshift
Bfft
Cifft
Drfft
Attempts:
3 left
💡 Hint
Common Mistakes
Using ifft instead of fft.
Using fftshift which only shifts the zero frequency component.
Using rfft which is for real input FFT but not the general FFT.
4fill in blank
hard

Fill both blanks to create a dictionary of word lengths for words longer than 3 characters.

NumPy
words = ['data', 'science', 'ai', 'ml']
lengths = {word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
Bword
C>
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself instead of its length.
Using the wrong comparison operator like <=.
5fill in blank
hard

Fill all three blanks to create a dictionary of uppercase words mapped to their lengths for words longer than 2 characters.

NumPy
words = ['fft', 'np', 'data', 'ai']
result = { [1]: [2] for word in words if len(word) [3] 2 }
Drag options to blanks, or click blank then click option'
Aword.upper()
Blen(word)
C>
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using the original word instead of uppercase.
Using the wrong comparison operator like <.