The following table lists an octave of music notes, beginning with middle C, along with their frequencies. Note Frequency (Hz) C4 261.63. Begin by writing a program that reads the name of a note from the user and displays the notes frequency. Your program should support all of the notes listed previously. Once you have your program working correctly for the notes listed previously you should add support for all of the notes from C0 to C8. While this could be done by adding many additional cases to your if statement, such a solution is cumbersome, inelegant and unacceptable for the purposes of this exercise. Instead, you should exploit the relationship between notes in adjacent octaves. In particular, the frequency of any note in octave n is half the frequency of the corresponding note in octave n+1.
By using this relationship, you should be able to add support for the additional notes without adding additional cases to your if statement.
Hint:
To complete this exercise you will need to extract individual characters from the two-character note name so that you can work with the letter and the octave number separately.
Once you have separated the parts, compute the frequency of the note in the fourth octave using the data in the table above.
Then divide the frequency by 2 power(4-x ), where x is the octave number entered by the user. (freq=freq/2**(4-octave))
This will halve or double the frequency the correct number of times.
Cnote=input("Enter the CNote: ") no=int(Cnote[1]) freq=(261.63/(2**(4-no))) print(freq) ''' INPUT C0 OUTPUT 16.351875 INPUT C3 OUTPUT 130.815 '''
More Codes to Fcuk
- Armstrong Number
- Find the biggest even number
- Program to replace every element on right side
- Compute the frequency of the note
- Print all Possible Combinations from three Digits.
- Get number n and Compute n+nn+nnn
- Print Cube root of the given number
- Convert number into binary, octal and hexa
- Return maximum number of operations performed on array.
- Determine the encryption key
- Find the count of numbers having a prime number in their binary representation.
- Fibonacci Series up to given n numbers
- Help Alice find the route to her home
Explore
- Quantum Mechanics relation with quantum computing
- Unzipping Files using Python
- An Algorithm which accepts n integer values and calculates the average and prints it.
- How can Quantum Computing merge with Virtual Reality ? !
- Blockchain and Cryptocurrency. And their relations with Virtual Reality !!