Mode Gelap

Recent in Fashion

Best Seller Books

Note To Frequency - A NOTE

  • Problem Description

    The following table lists an octave of music notes, beginning with middle A, along with their frequencies.

    Note Frequency (Hz) 

    A4 440.00

    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 A0 to A8. 

    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. This will halve or double the frequency the correct number of times.

    Then divide the frequency by 2 power(4-x ), where x is the octave number entered by the user. (freq=freq/2**(4-octave))
  • CODING ARENA
  • a=input()
    b=int(a[1])
    print(440//(2**(4-b)))
  • Test Case 1

    Input (stdin)
    A2

    Expected Output
    110
  • Test Case 2

    Input (stdin)
    A8

    Expected Output
    7040

Subscribe Our Newsletter

avatar
"By speaking behind my back, it means that you respect my existence enough not to act in front of my face."

Related Posts

0 Comment

Post a Comment

Article Top Ads

Parallax Ads

Article Center Ads

Article Bottom Ads