# print 17-tone equal temperment base = 0x3c # start on middle c for n in range(0, 18): pitch = n * 70.588 whole = int(pitch // 100) cents = pitch % 100 frac = round((256 * cents) / 100) print(' pitch %2d: #%02x%02x (%2d semitones, %5.2f cents)' % (n + 1, frac, base + whole, whole, cents))