Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # coding: utf-8
- import winsound
- import sys
- import time
- notes = {'A' : 440, 'B': 494, 'C' : 262, 'D' : 294, 'E' : 330, 'F' : 370, 'G' : 392}
- def imperial_march():
- """ TOCA MARCHA IMPERIAL DO STAR WARS """
- print("Tocando Imperial March")
- while 1:
- frequencias = [440, 440, 440, 349, 523, 440, 349, 523, 440, 659, 659, 659, 698, 523, 415, 349, 523, 440]
- duracoes = [500, 500, 500, 350, 150, 500, 350, 150, 1000, 500, 500, 500, 350, 150, 500, 350, 150, 1000]
- i = 0
- while i < len(frequencias):
- sys.stdout.write('-')
- sys.stdout.flush()
- winsound.Beep(frequencias[i], duracoes[i])
- i += 1
- def happy_birthday():
- global notes
- """ TOCA FELIZ ANIVERSARIO """
- print("Tocando Happy Birthday")
- while 1:
- frequencias = [notes['D'], notes['D'], notes['E'], notes['D'], notes['G'], notes['F']\
- ,notes['D'], notes['D'], notes['E'], notes['D'], notes['A'], notes['G']\
- ,notes['G'], notes['D'], notes['D'], notes['D'], notes['B'], notes['G']\
- ,notes['F'], notes['E'], notes['C'], notes['C'], notes['B'], notes['G']\
- ,notes['A'], notes['G']]
- i = 0
- while i < len(frequencias):
- sys.stdout.write('-')
- sys.stdout.flush()
- winsound.Beep(frequencias[i], int(frequencias[i]//.32))
- i += 1
- def alphabet():
- global notes
- print("Tocando Alphabet Song")
- while 1:
- frequencias = [notes['C'], notes['D'], notes['E'], notes['F'], notes['G']\
- ,notes['A'], notes['B'], notes['C'], notes['D']\
- ,notes['E'], notes['F'], notes['G'], notes['A'], notes['B']]
- i = 0
- while i < len(frequencias):
- sys.stdout.write('-')
- sys.stdout.flush()
- winsound.Beep(frequencias[i], int(frequencias[i]//.32))
- i += 1
- def menu():
- choices = {'happy birthday' : happy_birthday, 'alphabet' : alphabet, 'imperial march' : imperial_march}
- choice = input('Type a name of song: ').lower()
- if choice in choices:
- choices[choice]()
- else:
- print("Doesn't have your choice")
- if __name__ == '__main__':
- try:
- menu()
- except KeyboardInterrupt:
- print("Exiting", end='')
- for i in range(10):
- sys.stdout.write('.')
- sys.stdout.flush()
- time.sleep(0.020)
- else:
- print()
- sys.exit(9)
Advertisement
Add Comment
Please, Sign In to add comment