✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Complete playthattune.py by selecting one of the given code snippets below. The code snippet you select must enable playthattune.py to play the notes depicted in Figure A when it is executed.
Voltooi playthattune.py deur een van die gegewe kode uitreksels te kies. Die kode uitreksel wat jy kies moet playthattune.py in staat stel om die note wat in Figuur A uitgebeeld word te kan speel wanneer dit uitgevoer word.
import math#playthattune.pyimport stdaudioimport stdarray
sps = 44100def playnotes(pitch, duration): n = int(sps*duration)
hz = 440*math.pow(2,pitch[k]/12.0) a = stdarray.create1D(n+1,0.0) for i in range(0,n+1): a[i] = math.sin((2*math.pi*i*hz)/sps) stdaudio.playSamples(a) def main(): #YOUR CHOSEN CODE SNIPPET GOES HERE for k in range(0,len(pitch)): playnotes(A,0.5)
if __name__ == "__main__": main()
Figure A/Figuur A