How does each element in the output array of a DFT correspond to a specific frequency? I have a basic understanding of the Fourier Transform, though I'm trying to use it in a program and I'm confused on the specifics. Based on source code I can find online, the DFT takes a set of samples/numbers, performs a summation for each term, and returns a set of these summations which is the same size as the input set. Suppose I have a periodic function. As I understand it, the output array should contain the amplitudes/weights of each frequency which sum to that function. What I can't figure out is how each frequency is encoded in the array as just an index. In each example I read, we just assign a summation at each iteration of the inner loop to the next consecutive index in the output array. How are these indices indicative of which frequency they correspond to?
I'm attaching the source code I'm referencing to the bottom of this in case the website I linked to ever goes down.
import cmath
def compute_dft_complex(input):
    n = len(input)
    output = []
    for k in range(n):  # For each output element
        s = complex(0)
        for t in range(n):  # For each input element
            angle = 2j * cmath.pi * t * k / n
            s += input[t] * cmath.exp(-angle)
        output.append(s)
    return output
Let us denote the input signal by $x(0),\ldots,x(n-1)$ and the output signal by $y(0),\ldots,y(n-1)$. Your program is using the following formula:
$$
y(k) = \sum_{t=0}^{n-1} e^{-2\pi i tk/n} x(t).
$$
We also have
$$
x(t) = \frac{1}{n} \sum_{k=0}^{n-1} e^{2\pi i tk/n} y(k).
$$
In other words, any input signal can be represented as a linear combination of the functions $\chi_k(t) = e^{2\pi i tk/n}$, and the output signal gives the coefficients of this representation (up to a normalization factor).
The parameter $k$ is analogous to frequency. You can see the analogy more clearly if you write
$$
\chi_k(t) = \cos \frac{2\pi k}{n} t + i \sin \frac{2\pi k}{n} t.
$$