0
0
SciPydata~10 mins

Why Fourier transforms reveal frequencies in SciPy - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Fourier transform function from scipy.

SciPy
from scipy.fft import [1]
Drag options to blanks, or click blank then click option'
Afft
Bsin
Ccos
Dintegrate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sin' or 'cos' instead of 'fft' because they are trigonometric functions, not transform functions.
Trying to import 'integrate' which is unrelated here.
2fill in blank
medium

Complete the code to create a time array from 0 to 1 second with 500 points.

SciPy
import numpy as np
time = np.linspace(0, [1], 500)
Drag options to blanks, or click blank then click option'
A100
B1
C0.1
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using 10 or 100 which are too large for 1 second duration.
Using 0.1 which is too short.
3fill in blank
hard

Fix the error in the code to generate a signal with frequency 5 Hz.

SciPy
freq = 5
signal = np.sin(2 * np.pi * freq * [1])
Drag options to blanks, or click blank then click option'
Anp.pi
Bfreq
Cnp.linspace
Dtime
Attempts:
3 left
💡 Hint
Common Mistakes
Using frequency variable instead of time inside the sine function.
Using np.linspace which is a function, not a variable.
4fill in blank
hard

Fill both blanks to compute the Fourier transform and get the frequency bins.

SciPy
yf = [1](signal)
xf = np.fft.fftfreq(len(signal), [2])
Drag options to blanks, or click blank then click option'
Afft
B0.002
C0.01
Dsin
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sin' instead of 'fft' for the transform.
Using wrong sample spacing like 0.01 which does not match 500 points per second.
5fill in blank
hard

Fill both blanks to create a dictionary of frequencies and their amplitudes above a threshold.

SciPy
result = {xf[1]: abs(yf) for i, yf in enumerate(yf) if abs(yf) [2] 10}
Drag options to blanks, or click blank then click option'
A[i]
B>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of square brackets for indexing.
Using less than instead of greater than for filtering.