0
0
SciPydata~10 mins

WAV audio file handling in SciPy - Interactive Code Practice

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

Complete the code to read a WAV file using scipy.

SciPy
from scipy.io import wavfile
sample_rate, data = wavfile.[1]('audio.wav')
Drag options to blanks, or click blank then click option'
Aread
Bload
Cwrite
Dopen
Attempts:
3 left
💡 Hint
Common Mistakes
Using wavfile.write instead of wavfile.read
Trying to use wavfile.load which does not exist
2fill in blank
medium

Complete the code to write data to a WAV file using scipy.

SciPy
from scipy.io import wavfile
wavfile.[1]('output.wav', sample_rate, data)
Drag options to blanks, or click blank then click option'
Awrite
Bread
Csave
Dexport
Attempts:
3 left
💡 Hint
Common Mistakes
Using wavfile.read instead of wavfile.write
Trying to use wavfile.save which does not exist
3fill in blank
hard

Fix the error in the code to correctly read a WAV file and print its sample rate.

SciPy
from scipy.io import wavfile
sample_rate, data = wavfile.read('sound.wav')
print([1])
Drag options to blanks, or click blank then click option'
Adata
Bsample_rate
Cwavfile
Dsound.wav
Attempts:
3 left
💡 Hint
Common Mistakes
Printing the data array instead of sample rate
Printing the filename string instead of a variable
4fill in blank
hard

Fill both blanks to create a dictionary with word lengths for words longer than 3 letters.

SciPy
words = ['sound', 'wav', 'file', 'data', 'io']
lengths = {word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
B>
C<
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself instead of its length
Using less than < instead of greater than >
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase keys and values filtered by positive numbers.

SciPy
data = {'a': 1, 'b': -2, 'c': 3}
result = { [1]: [2] for k, v in data.items() if v [3] 0 }
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk
Attempts:
3 left
💡 Hint
Common Mistakes
Using original keys instead of uppercase
Including negative values by mistake