Ask Question

On a piano, each key has a frequency, and each subsequent key (black or white) is a known amount higher. Ex: The A key above middle C key has a frequency of 440 Hz. Each subsequent key (black or white) has a frequency of 440 * rn, where n is the number of keys from that A key, and r is 2 (1/12). Given an initial frequency, output that frequency and the next 3 higher key frequencies. If the input is 440, the output is: 440 493.883 523.251 554.365. Note: Include one statement to compute r = 2 (1/12) using the pow function, then use r in the formula fn = f0 * rn. (You'll have three statements using that formula, different only in the value for n).

+5
Answers (1)
  1. 14 April, 05:01
    0
    sample output

    Enter f0 = 440

    440.0,466.1637615180899, 493.8833012561241,

    523.2511306011974, 554.3652619537443

    Explanation:

    import math / / math library

    def RaiseToPower () : / / RaiseToPower method

    r = math. pow (2,1/12) / /r = 2^ (1/12)

    f0 = float (input ('Enter f0 : ')) / /input from user

    //a key has a frequency, sy f0

    print (f0, end=' ') / /Display statement

    for n in range (1,5) : / /Iterate the loop up to the next 4 higher key Hz

    n = f0 * math. pow (r, n) / /calculate the fn value

    print (fn, end=' ') / /Display statement

    RaiseToPower () / /Call RaiseToPower method
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “On a piano, each key has a frequency, and each subsequent key (black or white) is a known amount higher. Ex: The A key above middle C key ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers