logo

Crowdly

Browser

Додати до Chrome

Complete playthattune.py by selecting one of the given code snippets below. Th...

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

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. 

#playthattune.py

import stdaudio

import

math

import stdarray

def playnotes(pitch, duration):

    sps =

44100

    n = int(sps*duration)

    for k in range(0,len(pitch)):

        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

    playnotes(A,0.5)

if __name__ == "__main__": main()

 

                                 Figure A/Figuur A

Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на stemlearn.sun.ac.za?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!

Browser

Додати до Chrome