Skip to content

Instantly share code, notes, and snippets.

@spacekitcat
Created October 2, 2021 19:37
Show Gist options
  • Save spacekitcat/33df29ac51ac2cdeb7a1f0664732de08 to your computer and use it in GitHub Desktop.
Save spacekitcat/33df29ac51ac2cdeb7a1f0664732de08 to your computer and use it in GitHub Desktop.
Learning tool designed to drill the user on the distance between random note pairs to help reinforce a sense of scale geometry.
import random
def get_notes():
return ['c', 'c#', 'd', 'd#', 'e', 'f', 'f#', 'g', 'g#', 'a', 'a#', 'b']
def get_note_pair():
x = random.choice(range(0, len(get_notes()) - 1))
y = random.choice(range(x+1, len(get_notes())))
return (x, y)
def prompt_question(pair):
print(f'Distance between the notes {get_notes()[pair[0]]} and {get_notes()[pair[1]]}?')
def reveal_answer(note_pair):
print(f'The distance between {get_notes()[note_pair[0]]} and {get_notes()[note_pair[1]]} is {note_pair[1]-note_pair[0]}')
if __name__ == '__main__':
pair = get_note_pair()
prompt_question(pair)
answer = int(input('Answer:'))
diff = pair[1] - pair[0]
if diff == answer:
print('correct.')
else:
print(f'Incorrect. The difference is {diff}')
print(f'{get_notes()[pair[0]:pair[1]+1]}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment