def getFreq ( ):
noteRepresentation = "78!9@a#bc$d%ef^g&A*BC(D)EF_G+H"
x = noteRepresentation.find('g') # x becomes 15
y = noteRepresentation.find('H') # y becomes 29
exponent = (x - y)/12.0
freq = 440.0 * (2.0 ** exponent) # freq becomes 196.0 (if rounded)
print freq
def getFreq ( note ):
noteRepresentation = "78!9@a#bc$d%ef^g&A*BC(D)EF_G+H"
x = noteRepresentation.find( note ) # x location of parameter
y = noteRepresentation.find('H') # y becomes 29
exponent = (x - y)/12.0
freq = 440.0 * (2.0 ** exponent) # freq becomes 196.0 (if rounded)
return freq
def main():
char = 'a'
freq = getFreq ( char )
print "For the character", char, "the frequency is:", freq