← Back to challenges

Fret Frequencies on the Guitar

PythonHardmathnumbersalgorithms

Instructions

Create a function that takes a number of a guitar string and the number of the fret and returns the corresponding frequency of the note.

  • The formula to calculate the frequency is: String Frequency * 2**(fret/12).
  • Round the frequency to the nearest hundreth.
  • For this challenge, we use "Standard Tuning".

So, one fret = a semitone = a half step. From D to D♯ for instance.

Examples

fret_freq(5, 12) ➞ 220

fret_freq(4, 6) ➞ 207.65

fret_freq(2, 23) ➞ 932.32

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.