The question
A converter samples a short pulse 8000 times a second. We keep four samples: x[0] to x[3] are all 1, and every other x[n] is 0. The pulse lasts 4/8000 s = 0.5 ms.
The spectrum says how much of each frequency a signal holds. We test one frequency at a time. For samples, frequency ω is measured in radians per sample: ω = 2π·f/fs. Here ω = π/4, which is 1000 Hz.
Arrows for one frequency
For each n, e^(−jωn) = cos(ωn) − j·sin(ωn). That is an arrow of length 1 at angle −ωn. From one sample to the next it turns by ω. At ω = π/4 the arrows point to 0°, −45°, −90° and −135°.
Each sample scales its own arrow: x[n]·e^(−jωn). A bigger sample makes a longer arrow; a zero sample makes no arrow at all. All four samples here are 1, so every arrow keeps length 1.
Add the arrows by placing each one where the last one ends. The sum is the DTFT at this ω: X(e^jπ/4) = 1.00 − 2.41j. Its length, |X| = 2.61, says how much of 1000 Hz the pulse holds.
Other test frequencies
Turn the test frequency down to ω = 0. Every arrow now points the same way, so they add up fully: X(e^j0) = x[0] + x[1] + x[2] + x[3] = 4. A pulse holds a lot of the slowest frequencies.
At ω = π/2 (2000 Hz) the arrows turn 90° each time: right, down, left, up. Head to tail they close a square and end where they began. The sum is 0: this pulse holds none of 2000 Hz.
The whole spectrum
Now sweep ω from −π to π and plot the length |X| each time. The result is the spectrum of the pulse: tall at ω = 0, zero at ±π/2 and ±π. The DTFT gives a value at every ω, not just a few.
Keep turning past π. Since n is a whole number, adding 2π to ω turns each arrow by whole circles, so nothing changes. The DTFT repeats every 2π: the spectrum copies sampling makes. Only −π to π (±4000 Hz) is new.
With numpy (Python 3) the sum is one line: np.exp makes the arrows and np.sum adds them. A computer can only try a finite list of ω values. Choosing them well is the DFT, the next lesson.
The working
# step 1/10 · samples x[n] = 1 for n = 0, 1, 2, 3 x[n] = 0 for every other n fs = 8000 samples per second 4 samples × 1/8000 s = 0.5 ms question: which frequencies make up this pulse?
The four samples of 1 are a chosen example; 8000 samples a second is the telephone rate used in "What a signal is". Every arrow, sum and curve in the figure is computed from the DTFT definition in this model. On the dials the real part points right and the imaginary part points to the back of the table, so −j points toward you; in the flat plot −j points down.