Given that note, write a program which tells us the major scale starting at that note, using the pattern above. In the main block: Use a while loop to continue to ask for notes and then call a function get_scale. In the function get_scale, output the scale using the list. A hint is that you can encode the number of steps as a separate list of offsets. (Since a major scale will always have the same offs

Respuesta :

Solution and Explanation:

the_notes = ['C','C#','D','D#','E','F','F#','G','G#','A','A#','B'] #original list

def get_scale(choice): #function to get the major diatonic scale

steps=[1,1,.5,1,1,1,.5] #separate list for steps

size=None

for i in range(0,12): #loop to find out the index of the note entered

if(the_notes[i]==choice):

size =i

break

new_notes=the_notes[size:] + the_notes[:size]

#the above statement rotate the list so that the entered note can become the first note in the new list(i.e new notes)

index =0 #

scale="" #a string to store the major diatonic scale

for i in range(0,7):

scale+=new_notes[index]+" "

if(steps[i]==1):

index = index+2

else:

index=index+1

return scale

#main block

while(1):

choice=input("What scale do you want or Q to quit? ")

if(choice=='Q'):

break

elif(choice in the_notes):

print(get_scale(choice))

else:

print("That is not a note")